Permalink
Browse files

Move jest to version 20

Reviewed By: cpojer

Differential Revision: D5235642

fbshipit-source-id: eaeee1c5f67cf295fdc9798fb13bd5a83706af10
  • Loading branch information...
mjesun authored and facebook-github-bot committed Jun 14, 2017
1 parent 9250250 commit c9a39b3bd3a198564e7ef8c29adce931ccd8cae6
@@ -163,6 +163,7 @@ describe('promise tasks', () => {
}
beforeEach(() => {
jest.resetModules();
jest.useFakeTimers();
InteractionManager = require('InteractionManager');
BatchedBridge = require('BatchedBridge');
sequenceId = 0;
@@ -255,7 +256,9 @@ describe('promise tasks', () => {
expectToBeCalledOnce(task2);
});
const bigAsyncTest = () => {
const bigAsyncTest = (resolve) => {
jest.useRealTimers();
const task1 = createSequenceTask(1);
const task2 = jest.fn(() => {
expect(++sequenceId).toBe(2);
@@ -281,27 +284,25 @@ describe('promise tasks', () => {
InteractionManager.runAfterInteractions({gen: task2, name: 'gen2'});
InteractionManager.runAfterInteractions(task6);
jest.runAllTimers();
// runAllTimers doesn't actually run all timers with nested timer functions
// inside Promises, so we have to call it extra times.
jest.runAllTimers();
jest.runAllTimers();
setTimeout(() => {
expectToBeCalledOnce(task1);
expectToBeCalledOnce(task2);
expectToBeCalledOnce(task3);
expectToBeCalledOnce(task4);
expectToBeCalledOnce(task5);
expectToBeCalledOnce(task6);
expectToBeCalledOnce(task1);
expectToBeCalledOnce(task2);
expectToBeCalledOnce(task3);
expectToBeCalledOnce(task4);
expectToBeCalledOnce(task5);
expectToBeCalledOnce(task6);
resolve();
}, 100);
};
it('resolves async tasks recusively before other queued tasks', () => {
bigAsyncTest();
return new Promise(bigAsyncTest);
});
it('should also work with a deadline', () => {
InteractionManager.setDeadline(100);
BatchedBridge.getEventLoopRunningTime.mockReturnValue(200);
bigAsyncTest();
return new Promise(bigAsyncTest);
});
});
@@ -10,6 +10,8 @@
'use strict';
const Promise = require('promise');
function expectToBeCalledOnce(fn) {
expect(fn.mock.calls.length).toBe(1);
}
View
@@ -227,9 +227,9 @@
"eslint-plugin-flowtype": "^2.33.0",
"eslint-plugin-react": "^7.0.1",
"flow-bin": "^0.47.0",
"jest": "19.0.2",
"jest-repl": "19.0.2",
"jest-runtime": "^19.0.3",
"jest": "^20.0.4",
"jest-repl": "^20.0.4",
"jest-runtime": "^20.0.4",
"mock-fs": "^4.3.0",
"react": "16.0.0-alpha.12",
"react-test-renderer": "16.0.0-alpha.12",

0 comments on commit c9a39b3

Please sign in to comment.