Navigation Menu

Skip to content

Commit

Permalink
make test independent from side effects
Browse files Browse the repository at this point in the history
Reviewed By: jeanlauliac

Differential Revision: D4939025

fbshipit-source-id: cc7f811484cba0db4df394edef294cabe7343c8b
  • Loading branch information
davidaurelio authored and facebook-github-bot committed Apr 25, 2017
1 parent 5bb1e48 commit 291a497
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions packager/src/Bundler/__tests__/Bundler-test.js
Expand Up @@ -359,15 +359,25 @@ describe('Bundler', function() {
]));
});

it('return correct number of workers', () => {
os.cpus.mockReturnValue({length: 1});
expect(Bundler.getMaxWorkerCount()).toBe(1);
os.cpus.mockReturnValue({length: 8});
expect(Bundler.getMaxWorkerCount()).toBe(6);
os.cpus.mockReturnValue({length: 24});
expect(Bundler.getMaxWorkerCount()).toBe(14);
process.env.REACT_NATIVE_MAX_WORKERS = 5;
expect(Bundler.getMaxWorkerCount()).toBe(5);
describe('number of workers', () => {
beforeEach(() => {
delete process.env.REACT_NATIVE_MAX_WORKERS;
});

afterEach(() => {
delete process.env.REACT_NATIVE_MAX_WORKERS;
});

it('return correct number of workers', () => {
os.cpus.mockReturnValue({length: 1});
expect(Bundler.getMaxWorkerCount()).toBe(1);
os.cpus.mockReturnValue({length: 8});
expect(Bundler.getMaxWorkerCount()).toBe(6);
os.cpus.mockReturnValue({length: 24});
expect(Bundler.getMaxWorkerCount()).toBe(14);
process.env.REACT_NATIVE_MAX_WORKERS = 5;
expect(Bundler.getMaxWorkerCount()).toBe(5);
});
});
});
});

0 comments on commit 291a497

Please sign in to comment.