make test independent from side effects

Reviewed By: jeanlauliac

Differential Revision: D4939025

fbshipit-source-id: cc7f811484cba0db4df394edef294cabe7343c8b
This commit is contained in:
David Aurelio 2017-04-25 03:49:50 -07:00 committed by Facebook Github Bot
parent 5bb1e4813b
commit 291a497bc4
1 changed files with 19 additions and 9 deletions

View File

@ -359,15 +359,25 @@ describe('Bundler', function() {
])); ]));
}); });
it('return correct number of workers', () => { describe('number of workers', () => {
os.cpus.mockReturnValue({length: 1}); beforeEach(() => {
expect(Bundler.getMaxWorkerCount()).toBe(1); delete process.env.REACT_NATIVE_MAX_WORKERS;
os.cpus.mockReturnValue({length: 8}); });
expect(Bundler.getMaxWorkerCount()).toBe(6);
os.cpus.mockReturnValue({length: 24}); afterEach(() => {
expect(Bundler.getMaxWorkerCount()).toBe(14); delete process.env.REACT_NATIVE_MAX_WORKERS;
process.env.REACT_NATIVE_MAX_WORKERS = 5; });
expect(Bundler.getMaxWorkerCount()).toBe(5);
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);
});
}); });
}); });
}); });