Update Jest APIs on fbsource
Reviewed By: javache Differential Revision: D3229435 fb-gh-sync-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c fbshipit-source-id: b0e252d69e1f399a946fca6e98ef62ff44c2ef9c
This commit is contained in:
parent
192ab663b7
commit
d363b1f2e2
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('../getImageSource');
|
jest.unmock('../getImageSource');
|
||||||
|
|
||||||
var getImageSource = require('../getImageSource');
|
var getImageSource = require('../getImageSource');
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.autoMockOff()
|
.disableAutomock()
|
||||||
.setMock('Text', {})
|
.setMock('Text', {})
|
||||||
.setMock('View', {})
|
.setMock('View', {})
|
||||||
.setMock('Image', {})
|
.setMock('Image', {})
|
||||||
|
@ -22,7 +22,7 @@ describe('Animated', () => {
|
||||||
it('works end to end', () => {
|
it('works end to end', () => {
|
||||||
var anim = new Animated.Value(0);
|
var anim = new Animated.Value(0);
|
||||||
|
|
||||||
var callback = jest.genMockFunction();
|
var callback = jest.fn();
|
||||||
|
|
||||||
var node = new Animated.__PropsOnlyForTests({
|
var node = new Animated.__PropsOnlyForTests({
|
||||||
style: {
|
style: {
|
||||||
|
@ -75,7 +75,7 @@ describe('Animated', () => {
|
||||||
|
|
||||||
it('does not detach on updates', () => {
|
it('does not detach on updates', () => {
|
||||||
var anim = new Animated.Value(0);
|
var anim = new Animated.Value(0);
|
||||||
anim.__detach = jest.genMockFunction();
|
anim.__detach = jest.fn();
|
||||||
|
|
||||||
var c = new Animated.View();
|
var c = new Animated.View();
|
||||||
c.props = {
|
c.props = {
|
||||||
|
@ -101,11 +101,11 @@ describe('Animated', () => {
|
||||||
it('stops animation when detached', () => {
|
it('stops animation when detached', () => {
|
||||||
// jest environment doesn't have cancelAnimationFrame :(
|
// jest environment doesn't have cancelAnimationFrame :(
|
||||||
if (!window.cancelAnimationFrame) {
|
if (!window.cancelAnimationFrame) {
|
||||||
window.cancelAnimationFrame = jest.genMockFunction();
|
window.cancelAnimationFrame = jest.fn();
|
||||||
}
|
}
|
||||||
|
|
||||||
var anim = new Animated.Value(0);
|
var anim = new Animated.Value(0);
|
||||||
var callback = jest.genMockFunction();
|
var callback = jest.fn();
|
||||||
|
|
||||||
var c = new Animated.View();
|
var c = new Animated.View();
|
||||||
c.props = {
|
c.props = {
|
||||||
|
@ -125,14 +125,14 @@ describe('Animated', () => {
|
||||||
|
|
||||||
it('triggers callback when spring is at rest', () => {
|
it('triggers callback when spring is at rest', () => {
|
||||||
var anim = new Animated.Value(0);
|
var anim = new Animated.Value(0);
|
||||||
var callback = jest.genMockFunction();
|
var callback = jest.fn();
|
||||||
Animated.spring(anim, {toValue: 0, velocity: 0}).start(callback);
|
Animated.spring(anim, {toValue: 0, velocity: 0}).start(callback);
|
||||||
expect(callback).toBeCalled();
|
expect(callback).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('send toValue when a spring stops', () => {
|
it('send toValue when a spring stops', () => {
|
||||||
var anim = new Animated.Value(0);
|
var anim = new Animated.Value(0);
|
||||||
var listener = jest.genMockFunction();
|
var listener = jest.fn();
|
||||||
anim.addListener(listener);
|
anim.addListener(listener);
|
||||||
Animated.spring(anim, {toValue: 15}).start();
|
Animated.spring(anim, {toValue: 15}).start();
|
||||||
jest.runAllTimers();
|
jest.runAllTimers();
|
||||||
|
@ -148,15 +148,15 @@ describe('Animated', () => {
|
||||||
describe('Animated Sequence', () => {
|
describe('Animated Sequence', () => {
|
||||||
|
|
||||||
it('works with an empty sequence', () => {
|
it('works with an empty sequence', () => {
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
Animated.sequence([]).start(cb);
|
Animated.sequence([]).start(cb);
|
||||||
expect(cb).toBeCalledWith({finished: true});
|
expect(cb).toBeCalledWith({finished: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('sequences well', () => {
|
it('sequences well', () => {
|
||||||
var anim1 = {start: jest.genMockFunction()};
|
var anim1 = {start: jest.fn()};
|
||||||
var anim2 = {start: jest.genMockFunction()};
|
var anim2 = {start: jest.fn()};
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
|
|
||||||
var seq = Animated.sequence([anim1, anim2]);
|
var seq = Animated.sequence([anim1, anim2]);
|
||||||
|
|
||||||
|
@ -179,9 +179,9 @@ describe('Animated Sequence', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports interrupting sequence', () => {
|
it('supports interrupting sequence', () => {
|
||||||
var anim1 = {start: jest.genMockFunction()};
|
var anim1 = {start: jest.fn()};
|
||||||
var anim2 = {start: jest.genMockFunction()};
|
var anim2 = {start: jest.fn()};
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
|
|
||||||
Animated.sequence([anim1, anim2]).start(cb);
|
Animated.sequence([anim1, anim2]).start(cb);
|
||||||
|
|
||||||
|
@ -193,9 +193,9 @@ describe('Animated Sequence', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports stopping sequence', () => {
|
it('supports stopping sequence', () => {
|
||||||
var anim1 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
|
var anim1 = {start: jest.fn(), stop: jest.fn()};
|
||||||
var anim2 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
|
var anim2 = {start: jest.fn(), stop: jest.fn()};
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
|
|
||||||
var seq = Animated.sequence([anim1, anim2]);
|
var seq = Animated.sequence([anim1, anim2]);
|
||||||
seq.start(cb);
|
seq.start(cb);
|
||||||
|
@ -215,14 +215,14 @@ describe('Animated Sequence', () => {
|
||||||
describe('Animated Parallel', () => {
|
describe('Animated Parallel', () => {
|
||||||
|
|
||||||
it('works with an empty parallel', () => {
|
it('works with an empty parallel', () => {
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
Animated.parallel([]).start(cb);
|
Animated.parallel([]).start(cb);
|
||||||
expect(cb).toBeCalledWith({finished: true});
|
expect(cb).toBeCalledWith({finished: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works with an empty element in array', () => {
|
it('works with an empty element in array', () => {
|
||||||
var anim1 = {start: jest.genMockFunction()};
|
var anim1 = {start: jest.fn()};
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
Animated.parallel([null, anim1]).start(cb);
|
Animated.parallel([null, anim1]).start(cb);
|
||||||
|
|
||||||
expect(anim1.start).toBeCalled();
|
expect(anim1.start).toBeCalled();
|
||||||
|
@ -232,9 +232,9 @@ describe('Animated Parallel', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parellelizes well', () => {
|
it('parellelizes well', () => {
|
||||||
var anim1 = {start: jest.genMockFunction()};
|
var anim1 = {start: jest.fn()};
|
||||||
var anim2 = {start: jest.genMockFunction()};
|
var anim2 = {start: jest.fn()};
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
|
|
||||||
var par = Animated.parallel([anim1, anim2]);
|
var par = Animated.parallel([anim1, anim2]);
|
||||||
|
|
||||||
|
@ -255,9 +255,9 @@ describe('Animated Parallel', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports stopping parallel', () => {
|
it('supports stopping parallel', () => {
|
||||||
var anim1 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
|
var anim1 = {start: jest.fn(), stop: jest.fn()};
|
||||||
var anim2 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
|
var anim2 = {start: jest.fn(), stop: jest.fn()};
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
|
|
||||||
var seq = Animated.parallel([anim1, anim2]);
|
var seq = Animated.parallel([anim1, anim2]);
|
||||||
seq.start(cb);
|
seq.start(cb);
|
||||||
|
@ -276,10 +276,10 @@ describe('Animated Parallel', () => {
|
||||||
|
|
||||||
|
|
||||||
it('does not call stop more than once when stopping', () => {
|
it('does not call stop more than once when stopping', () => {
|
||||||
var anim1 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
|
var anim1 = {start: jest.fn(), stop: jest.fn()};
|
||||||
var anim2 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
|
var anim2 = {start: jest.fn(), stop: jest.fn()};
|
||||||
var anim3 = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
|
var anim3 = {start: jest.fn(), stop: jest.fn()};
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
|
|
||||||
var seq = Animated.parallel([anim1, anim2, anim3]);
|
var seq = Animated.parallel([anim1, anim2, anim3]);
|
||||||
seq.start(cb);
|
seq.start(cb);
|
||||||
|
@ -306,8 +306,8 @@ describe('Animated Parallel', () => {
|
||||||
|
|
||||||
describe('Animated delays', () => {
|
describe('Animated delays', () => {
|
||||||
it('should call anim after delay in sequence', () => {
|
it('should call anim after delay in sequence', () => {
|
||||||
var anim = {start: jest.genMockFunction(), stop: jest.genMockFunction()};
|
var anim = {start: jest.fn(), stop: jest.fn()};
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
Animated.sequence([
|
Animated.sequence([
|
||||||
Animated.delay(1000),
|
Animated.delay(1000),
|
||||||
anim,
|
anim,
|
||||||
|
@ -319,7 +319,7 @@ describe('Animated delays', () => {
|
||||||
expect(cb).toBeCalledWith({finished: true});
|
expect(cb).toBeCalledWith({finished: true});
|
||||||
});
|
});
|
||||||
it('should run stagger to end', () => {
|
it('should run stagger to end', () => {
|
||||||
var cb = jest.genMockFunction();
|
var cb = jest.fn();
|
||||||
Animated.stagger(1000, [
|
Animated.stagger(1000, [
|
||||||
Animated.delay(1000),
|
Animated.delay(1000),
|
||||||
Animated.delay(1000),
|
Animated.delay(1000),
|
||||||
|
@ -341,7 +341,7 @@ describe('Animated Events', () => {
|
||||||
});
|
});
|
||||||
it('should call listeners', () => {
|
it('should call listeners', () => {
|
||||||
var value = new Animated.Value(0);
|
var value = new Animated.Value(0);
|
||||||
var listener = jest.genMockFunction();
|
var listener = jest.fn();
|
||||||
var handler = Animated.event(
|
var handler = Animated.event(
|
||||||
[{foo: value}],
|
[{foo: value}],
|
||||||
{listener},
|
{listener},
|
||||||
|
@ -366,14 +366,14 @@ describe('Animated Interactions', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(()=> {
|
afterEach(()=> {
|
||||||
jest.dontMock('InteractionManager');
|
jest.unmock('InteractionManager');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('registers an interaction by default', () => {
|
it('registers an interaction by default', () => {
|
||||||
InteractionManager.createInteractionHandle.mockReturnValue(777);
|
InteractionManager.createInteractionHandle.mockReturnValue(777);
|
||||||
|
|
||||||
var value = new Animated.Value(0);
|
var value = new Animated.Value(0);
|
||||||
var callback = jest.genMockFunction();
|
var callback = jest.fn();
|
||||||
Animated.timing(value, {
|
Animated.timing(value, {
|
||||||
toValue: 100,
|
toValue: 100,
|
||||||
duration: 100,
|
duration: 100,
|
||||||
|
@ -387,7 +387,7 @@ describe('Animated Interactions', () => {
|
||||||
|
|
||||||
it('does not register an interaction when specified', () => {
|
it('does not register an interaction when specified', () => {
|
||||||
var value = new Animated.Value(0);
|
var value = new Animated.Value(0);
|
||||||
var callback = jest.genMockFunction();
|
var callback = jest.fn();
|
||||||
Animated.timing(value, {
|
Animated.timing(value, {
|
||||||
toValue: 100,
|
toValue: 100,
|
||||||
duration: 100,
|
duration: 100,
|
||||||
|
@ -451,7 +451,7 @@ describe('Animated Vectors', () => {
|
||||||
it('should animate vectors', () => {
|
it('should animate vectors', () => {
|
||||||
var vec = new Animated.ValueXY();
|
var vec = new Animated.ValueXY();
|
||||||
|
|
||||||
var callback = jest.genMockFunction();
|
var callback = jest.fn();
|
||||||
|
|
||||||
var node = new Animated.__PropsOnlyForTests({
|
var node = new Animated.__PropsOnlyForTests({
|
||||||
style: {
|
style: {
|
||||||
|
@ -536,7 +536,7 @@ describe('Animated Vectors', () => {
|
||||||
describe('Animated Listeners', () => {
|
describe('Animated Listeners', () => {
|
||||||
it('should get updates', () => {
|
it('should get updates', () => {
|
||||||
var value1 = new Animated.Value(0);
|
var value1 = new Animated.Value(0);
|
||||||
var listener = jest.genMockFunction();
|
var listener = jest.fn();
|
||||||
var id = value1.addListener(listener);
|
var id = value1.addListener(listener);
|
||||||
value1.setValue(42);
|
value1.setValue(42);
|
||||||
expect(listener.mock.calls.length).toBe(1);
|
expect(listener.mock.calls.length).toBe(1);
|
||||||
|
@ -554,7 +554,7 @@ describe('Animated Listeners', () => {
|
||||||
|
|
||||||
it('should removeAll', () => {
|
it('should removeAll', () => {
|
||||||
var value1 = new Animated.Value(0);
|
var value1 = new Animated.Value(0);
|
||||||
var listener = jest.genMockFunction();
|
var listener = jest.fn();
|
||||||
[1,2,3,4].forEach(() => value1.addListener(listener));
|
[1,2,3,4].forEach(() => value1.addListener(listener));
|
||||||
value1.setValue(42);
|
value1.setValue(42);
|
||||||
expect(listener.mock.calls.length).toBe(4);
|
expect(listener.mock.calls.length).toBe(4);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.autoMockOff()
|
.disableAutomock()
|
||||||
.setMock('Text', {})
|
.setMock('Text', {})
|
||||||
.setMock('View', {})
|
.setMock('View', {})
|
||||||
.setMock('Image', {})
|
.setMock('Image', {})
|
||||||
|
@ -24,19 +24,19 @@ describe('Animated', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
|
var nativeAnimatedModule = require('NativeModules').NativeAnimatedModule;
|
||||||
nativeAnimatedModule.createAnimatedNode = jest.genMockFunction();
|
nativeAnimatedModule.createAnimatedNode = jest.fn();
|
||||||
nativeAnimatedModule.connectAnimatedNodes = jest.genMockFunction();
|
nativeAnimatedModule.connectAnimatedNodes = jest.fn();
|
||||||
nativeAnimatedModule.disconnectAnimatedNodes = jest.genMockFunction();
|
nativeAnimatedModule.disconnectAnimatedNodes = jest.fn();
|
||||||
nativeAnimatedModule.startAnimatingNode = jest.genMockFunction();
|
nativeAnimatedModule.startAnimatingNode = jest.fn();
|
||||||
nativeAnimatedModule.stopAnimation = jest.genMockFunction();
|
nativeAnimatedModule.stopAnimation = jest.fn();
|
||||||
nativeAnimatedModule.setAnimatedNodeValue = jest.genMockFunction();
|
nativeAnimatedModule.setAnimatedNodeValue = jest.fn();
|
||||||
nativeAnimatedModule.connectAnimatedNodeToView = jest.genMockFunction();
|
nativeAnimatedModule.connectAnimatedNodeToView = jest.fn();
|
||||||
nativeAnimatedModule.disconnectAnimatedNodeFromView = jest.genMockFunction();
|
nativeAnimatedModule.disconnectAnimatedNodeFromView = jest.fn();
|
||||||
nativeAnimatedModule.dropAnimatedNode = jest.genMockFunction();
|
nativeAnimatedModule.dropAnimatedNode = jest.fn();
|
||||||
|
|
||||||
// jest environment doesn't have cancelAnimationFrame :(
|
// jest environment doesn't have cancelAnimationFrame :(
|
||||||
if (!window.cancelAnimationFrame) {
|
if (!window.cancelAnimationFrame) {
|
||||||
window.cancelAnimationFrame = jest.genMockFunction();
|
window.cancelAnimationFrame = jest.fn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('Easing');
|
jest.unmock('Easing');
|
||||||
|
|
||||||
var Easing = require('Easing');
|
var Easing = require('Easing');
|
||||||
describe('Easing', () => {
|
describe('Easing', () => {
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('Interpolation')
|
.unmock('Interpolation')
|
||||||
.dontMock('Easing')
|
.unmock('Easing')
|
||||||
.dontMock('normalizeColor');
|
.unmock('normalizeColor');
|
||||||
|
|
||||||
var Interpolation = require('Interpolation');
|
var Interpolation = require('Interpolation');
|
||||||
var Easing = require('Easing');
|
var Easing = require('Easing');
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
jest.dontMock('bezier');
|
jest.unmock('bezier');
|
||||||
var bezier = require('bezier');
|
var bezier = require('bezier');
|
||||||
|
|
||||||
var identity = function (x) { return x; };
|
var identity = function (x) { return x; };
|
||||||
|
|
|
@ -10,21 +10,19 @@ var NativeModules = {
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
Timing: {
|
Timing: {
|
||||||
createTimer: jest.genMockFunction(),
|
createTimer: jest.fn(),
|
||||||
deleteTimer: jest.genMockFunction(),
|
deleteTimer: jest.fn(),
|
||||||
},
|
},
|
||||||
GraphPhotoUpload: {
|
GraphPhotoUpload: {
|
||||||
upload: jest.genMockFunction(),
|
upload: jest.fn(),
|
||||||
},
|
},
|
||||||
FacebookSDK: {
|
FacebookSDK: {
|
||||||
login: jest.genMockFunction(),
|
login: jest.fn(),
|
||||||
logout: jest.genMockFunction(),
|
logout: jest.fn(),
|
||||||
queryGraphPath: jest.genMockFunction().mockImpl(
|
queryGraphPath: jest.fn((path, method, params, callback) => callback()),
|
||||||
(path, method, params, callback) => callback()
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
DataManager: {
|
DataManager: {
|
||||||
queryData: jest.genMockFunction(),
|
queryData: jest.fn(),
|
||||||
},
|
},
|
||||||
UIManager: {
|
UIManager: {
|
||||||
customBubblingEventTypes: {},
|
customBubblingEventTypes: {},
|
||||||
|
@ -38,10 +36,10 @@ var NativeModules = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
AsyncLocalStorage: {
|
AsyncLocalStorage: {
|
||||||
getItem: jest.genMockFunction(),
|
getItem: jest.fn(),
|
||||||
setItem: jest.genMockFunction(),
|
setItem: jest.fn(),
|
||||||
removeItem: jest.genMockFunction(),
|
removeItem: jest.fn(),
|
||||||
clear: jest.genMockFunction(),
|
clear: jest.fn(),
|
||||||
},
|
},
|
||||||
SourceCode: {
|
SourceCode: {
|
||||||
scriptURL: null,
|
scriptURL: null,
|
||||||
|
@ -52,10 +50,10 @@ var NativeModules = {
|
||||||
},
|
},
|
||||||
ModalFullscreenViewManager: {},
|
ModalFullscreenViewManager: {},
|
||||||
AlertManager: {
|
AlertManager: {
|
||||||
alertWithArgs: jest.genMockFunction(),
|
alertWithArgs: jest.fn(),
|
||||||
},
|
},
|
||||||
Clipboard: {
|
Clipboard: {
|
||||||
setString: jest.genMockFunction(),
|
setString: jest.fn(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('NavigationLegacyNavigatorRouteStack');
|
jest.unmock('NavigationLegacyNavigatorRouteStack');
|
||||||
|
|
||||||
const NavigationLegacyNavigatorRouteStack = require('NavigationLegacyNavigatorRouteStack');
|
const NavigationLegacyNavigatorRouteStack = require('NavigationLegacyNavigatorRouteStack');
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.autoMockOff()
|
.disableAutomock()
|
||||||
.mock('ErrorUtils');
|
.mock('ErrorUtils');
|
||||||
|
|
||||||
var NavigationContext = require('NavigationContext');
|
var NavigationContext = require('NavigationContext');
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('NavigationEvent')
|
.unmock('NavigationEvent')
|
||||||
.dontMock('fbjs/lib/invariant');
|
.unmock('fbjs/lib/invariant');
|
||||||
|
|
||||||
var NavigationEvent = require('NavigationEvent');
|
var NavigationEvent = require('NavigationEvent');
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('EmitterSubscription')
|
.unmock('EmitterSubscription')
|
||||||
.dontMock('EventSubscription')
|
.unmock('EventSubscription')
|
||||||
.dontMock('EventEmitter')
|
.unmock('EventEmitter')
|
||||||
.dontMock('EventSubscriptionVendor')
|
.unmock('EventSubscriptionVendor')
|
||||||
.dontMock('NavigationEvent')
|
.unmock('NavigationEvent')
|
||||||
.dontMock('NavigationEventEmitter');
|
.unmock('NavigationEventEmitter');
|
||||||
|
|
||||||
var NavigationEventEmitter = require('NavigationEventEmitter');
|
var NavigationEventEmitter = require('NavigationEventEmitter');
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.autoMockOff()
|
.disableAutomock()
|
||||||
.mock('ErrorUtils');
|
.mock('ErrorUtils');
|
||||||
|
|
||||||
var NavigationRouteStack = require('NavigationRouteStack');
|
var NavigationRouteStack = require('NavigationRouteStack');
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('NavigationTreeNode')
|
.unmock('NavigationTreeNode')
|
||||||
.dontMock('fbjs/lib/invariant')
|
.unmock('fbjs/lib/invariant')
|
||||||
.dontMock('immutable');
|
.unmock('immutable');
|
||||||
|
|
||||||
var NavigationTreeNode = require('NavigationTreeNode');
|
var NavigationTreeNode = require('NavigationTreeNode');
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('AssetRegistry')
|
.unmock('AssetRegistry')
|
||||||
.dontMock('AssetSourceResolver')
|
.unmock('AssetSourceResolver')
|
||||||
.dontMock('../resolveAssetSource')
|
.unmock('../resolveAssetSource')
|
||||||
.dontMock('../../../local-cli/bundle/assetPathUtils');
|
.unmock('../../../local-cli/bundle/assetPathUtils');
|
||||||
|
|
||||||
var AssetRegistry = require('AssetRegistry');
|
var AssetRegistry = require('AssetRegistry');
|
||||||
var Platform = require('Platform');
|
var Platform = require('Platform');
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.autoMockOff()
|
.disableAutomock()
|
||||||
.mock('ErrorUtils')
|
.mock('ErrorUtils')
|
||||||
.mock('BatchedBridge');
|
.mock('BatchedBridge');
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ describe('InteractionManager', () => {
|
||||||
jest.resetModuleRegistry();
|
jest.resetModuleRegistry();
|
||||||
InteractionManager = require('InteractionManager');
|
InteractionManager = require('InteractionManager');
|
||||||
|
|
||||||
interactionStart = jest.genMockFunction();
|
interactionStart = jest.fn();
|
||||||
interactionComplete = jest.genMockFunction();
|
interactionComplete = jest.fn();
|
||||||
|
|
||||||
InteractionManager.addListener(
|
InteractionManager.addListener(
|
||||||
InteractionManager.Events.interactionStart,
|
InteractionManager.Events.interactionStart,
|
||||||
|
@ -84,7 +84,7 @@ describe('InteractionManager', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs tasks asynchronously when there are interactions', () => {
|
it('runs tasks asynchronously when there are interactions', () => {
|
||||||
var task = jest.genMockFunction();
|
var task = jest.fn();
|
||||||
InteractionManager.runAfterInteractions(task);
|
InteractionManager.runAfterInteractions(task);
|
||||||
expect(task).not.toBeCalled();
|
expect(task).not.toBeCalled();
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ describe('InteractionManager', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs tasks when interactions complete', () => {
|
it('runs tasks when interactions complete', () => {
|
||||||
var task = jest.genMockFunction();
|
var task = jest.fn();
|
||||||
var handle = InteractionManager.createInteractionHandle();
|
var handle = InteractionManager.createInteractionHandle();
|
||||||
InteractionManager.runAfterInteractions(task);
|
InteractionManager.runAfterInteractions(task);
|
||||||
|
|
||||||
|
@ -106,8 +106,8 @@ describe('InteractionManager', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not run tasks twice', () => {
|
it('does not run tasks twice', () => {
|
||||||
var task1 = jest.genMockFunction();
|
var task1 = jest.fn();
|
||||||
var task2 = jest.genMockFunction();
|
var task2 = jest.fn();
|
||||||
InteractionManager.runAfterInteractions(task1);
|
InteractionManager.runAfterInteractions(task1);
|
||||||
jest.runAllTimers();
|
jest.runAllTimers();
|
||||||
|
|
||||||
|
@ -118,10 +118,10 @@ describe('InteractionManager', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs tasks added while processing previous tasks', () => {
|
it('runs tasks added while processing previous tasks', () => {
|
||||||
var task1 = jest.genMockFunction().mockImplementation(() => {
|
var task1 = jest.fn(() => {
|
||||||
InteractionManager.runAfterInteractions(task2);
|
InteractionManager.runAfterInteractions(task2);
|
||||||
});
|
});
|
||||||
var task2 = jest.genMockFunction();
|
var task2 = jest.fn();
|
||||||
|
|
||||||
InteractionManager.runAfterInteractions(task1);
|
InteractionManager.runAfterInteractions(task1);
|
||||||
expect(task2).not.toBeCalled();
|
expect(task2).not.toBeCalled();
|
||||||
|
@ -138,7 +138,7 @@ describe('promise tasks', () => {
|
||||||
let BatchedBridge;
|
let BatchedBridge;
|
||||||
let sequenceId;
|
let sequenceId;
|
||||||
function createSequenceTask(expectedSequenceId) {
|
function createSequenceTask(expectedSequenceId) {
|
||||||
return jest.genMockFunction().mockImplementation(() => {
|
return jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(expectedSequenceId);
|
expect(++sequenceId).toBe(expectedSequenceId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ describe('promise tasks', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should run a basic promise task', () => {
|
it('should run a basic promise task', () => {
|
||||||
const task1 = jest.genMockFunction().mockImplementation(() => {
|
const task1 = jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(1);
|
expect(++sequenceId).toBe(1);
|
||||||
return new Promise(resolve => resolve());
|
return new Promise(resolve => resolve());
|
||||||
});
|
});
|
||||||
|
@ -161,14 +161,14 @@ describe('promise tasks', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle nested promises', () => {
|
it('should handle nested promises', () => {
|
||||||
const task1 = jest.genMockFunction().mockImplementation(() => {
|
const task1 = jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(1);
|
expect(++sequenceId).toBe(1);
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
InteractionManager.runAfterInteractions({gen: task2, name: 'gen2'})
|
InteractionManager.runAfterInteractions({gen: task2, name: 'gen2'})
|
||||||
.then(resolve);
|
.then(resolve);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const task2 = jest.genMockFunction().mockImplementation(() => {
|
const task2 = jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(2);
|
expect(++sequenceId).toBe(2);
|
||||||
return new Promise(resolve => resolve());
|
return new Promise(resolve => resolve());
|
||||||
});
|
});
|
||||||
|
@ -180,7 +180,7 @@ describe('promise tasks', () => {
|
||||||
|
|
||||||
it('should pause promise tasks during interactions then resume', () => {
|
it('should pause promise tasks during interactions then resume', () => {
|
||||||
const task1 = createSequenceTask(1);
|
const task1 = createSequenceTask(1);
|
||||||
const task2 = jest.genMockFunction().mockImplementation(() => {
|
const task2 = jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(2);
|
expect(++sequenceId).toBe(2);
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
@ -238,7 +238,7 @@ describe('promise tasks', () => {
|
||||||
|
|
||||||
const bigAsyncTest = () => {
|
const bigAsyncTest = () => {
|
||||||
const task1 = createSequenceTask(1);
|
const task1 = createSequenceTask(1);
|
||||||
const task2 = jest.genMockFunction().mockImplementation(() => {
|
const task2 = jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(2);
|
expect(++sequenceId).toBe(2);
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
InteractionManager.runAfterInteractions(task3);
|
InteractionManager.runAfterInteractions(task3);
|
||||||
|
@ -249,7 +249,7 @@ describe('promise tasks', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const task3 = createSequenceTask(3);
|
const task3 = createSequenceTask(3);
|
||||||
const task4 = jest.genMockFunction().mockImplementation(() => {
|
const task4 = jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(4);
|
expect(++sequenceId).toBe(4);
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
InteractionManager.runAfterInteractions(task5).then(resolve);
|
InteractionManager.runAfterInteractions(task5).then(resolve);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('InteractionMixin');
|
jest.unmock('InteractionMixin');
|
||||||
|
|
||||||
describe('InteractionMixin', () => {
|
describe('InteractionMixin', () => {
|
||||||
var InteractionManager;
|
var InteractionManager;
|
||||||
|
@ -36,7 +36,7 @@ describe('InteractionMixin', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should schedule tasks', () => {
|
it('should schedule tasks', () => {
|
||||||
var task = jest.genMockFunction();
|
var task = jest.fn();
|
||||||
component.runAfterInteractions(task);
|
component.runAfterInteractions(task);
|
||||||
expect(InteractionManager.runAfterInteractions).toBeCalledWith(task);
|
expect(InteractionManager.runAfterInteractions).toBeCalledWith(task);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('TaskQueue');
|
jest.unmock('TaskQueue');
|
||||||
|
|
||||||
function expectToBeCalledOnce(fn) {
|
function expectToBeCalledOnce(fn) {
|
||||||
expect(fn.mock.calls.length).toBe(1);
|
expect(fn.mock.calls.length).toBe(1);
|
||||||
|
@ -23,13 +23,13 @@ describe('TaskQueue', () => {
|
||||||
let onMoreTasks;
|
let onMoreTasks;
|
||||||
let sequenceId;
|
let sequenceId;
|
||||||
function createSequenceTask(expectedSequenceId) {
|
function createSequenceTask(expectedSequenceId) {
|
||||||
return jest.genMockFunction().mockImplementation(() => {
|
return jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(expectedSequenceId);
|
expect(++sequenceId).toBe(expectedSequenceId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.resetModuleRegistry();
|
jest.resetModuleRegistry();
|
||||||
onMoreTasks = jest.genMockFunction();
|
onMoreTasks = jest.fn();
|
||||||
const TaskQueue = require('TaskQueue');
|
const TaskQueue = require('TaskQueue');
|
||||||
taskQueue = new TaskQueue({onMoreTasks});
|
taskQueue = new TaskQueue({onMoreTasks});
|
||||||
sequenceId = 0;
|
sequenceId = 0;
|
||||||
|
@ -45,7 +45,7 @@ describe('TaskQueue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle blocking promise task', () => {
|
it('should handle blocking promise task', () => {
|
||||||
const task1 = jest.genMockFunction().mockImplementation(() => {
|
const task1 = jest.fn(() => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(++sequenceId).toBe(1);
|
expect(++sequenceId).toBe(1);
|
||||||
|
@ -71,7 +71,7 @@ describe('TaskQueue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle nested simple tasks', () => {
|
it('should handle nested simple tasks', () => {
|
||||||
const task1 = jest.genMockFunction().mockImplementation(() => {
|
const task1 = jest.fn(() => {
|
||||||
expect(++sequenceId).toBe(1);
|
expect(++sequenceId).toBe(1);
|
||||||
taskQueue.enqueue({run: task3, name: 'run3'});
|
taskQueue.enqueue({run: task3, name: 'run3'});
|
||||||
});
|
});
|
||||||
|
@ -88,7 +88,7 @@ describe('TaskQueue', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle nested promises', () => {
|
it('should handle nested promises', () => {
|
||||||
const task1 = jest.genMockFunction().mockImplementation(() => {
|
const task1 = jest.fn(() => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(++sequenceId).toBe(1);
|
expect(++sequenceId).toBe(1);
|
||||||
|
@ -97,7 +97,7 @@ describe('TaskQueue', () => {
|
||||||
}, 1);
|
}, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const task2 = jest.genMockFunction().mockImplementation(() => {
|
const task2 = jest.fn(() => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(++sequenceId).toBe(2);
|
expect(++sequenceId).toBe(2);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
var parseErrorStack = require('parseErrorStack');
|
var parseErrorStack = require('parseErrorStack');
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('NavigationFindReducer');
|
.unmock('NavigationFindReducer');
|
||||||
|
|
||||||
const NavigationFindReducer = require('NavigationFindReducer');
|
const NavigationFindReducer = require('NavigationFindReducer');
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('NavigationScenesReducer');
|
jest.unmock('NavigationScenesReducer');
|
||||||
|
|
||||||
const NavigationScenesReducer = require('NavigationScenesReducer');
|
const NavigationScenesReducer = require('NavigationScenesReducer');
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('NavigationStackReducer')
|
.unmock('NavigationStackReducer')
|
||||||
.dontMock('NavigationStateUtils');
|
.unmock('NavigationStateUtils');
|
||||||
|
|
||||||
jest.setMock('React', {Component() {}, PropTypes: {}});
|
jest.setMock('React', {Component() {}, PropTypes: {}});
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('NavigationTabsReducer')
|
.unmock('NavigationTabsReducer')
|
||||||
.dontMock('NavigationFindReducer')
|
.unmock('NavigationFindReducer')
|
||||||
.dontMock('NavigationStateUtils');
|
.unmock('NavigationStateUtils');
|
||||||
|
|
||||||
const NavigationTabsReducer = require('NavigationTabsReducer');
|
const NavigationTabsReducer = require('NavigationTabsReducer');
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('NavigationStateUtils');
|
.unmock('NavigationStateUtils');
|
||||||
|
|
||||||
var NavigationStateUtils = require('NavigationStateUtils');
|
var NavigationStateUtils = require('NavigationStateUtils');
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.autoMockOff()
|
.disableAutomock()
|
||||||
.dontMock('XMLHttpRequestBase');
|
.unmock('XMLHttpRequestBase');
|
||||||
|
|
||||||
const XMLHttpRequestBase = require('XMLHttpRequestBase');
|
const XMLHttpRequestBase = require('XMLHttpRequestBase');
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
var flattenStyle = require('flattenStyle');
|
var flattenStyle = require('flattenStyle');
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('normalizeColor');
|
jest.unmock('normalizeColor');
|
||||||
|
|
||||||
var normalizeColor = require('normalizeColor');
|
var normalizeColor = require('normalizeColor');
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
var processColor = require('processColor');
|
var processColor = require('processColor');
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('setNormalizedColorAlpha');
|
jest.unmock('setNormalizedColorAlpha');
|
||||||
jest.dontMock('normalizeColor');
|
jest.unmock('normalizeColor');
|
||||||
|
|
||||||
var setNormalizedColorAlpha = require('setNormalizedColorAlpha');
|
var setNormalizedColorAlpha = require('setNormalizedColorAlpha');
|
||||||
var normalizeColor = require('normalizeColor');
|
var normalizeColor = require('normalizeColor');
|
||||||
|
|
|
@ -13,12 +13,12 @@ function reportError(error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrorUtils = {
|
var ErrorUtils = {
|
||||||
apply: jest.genMockFunction().mockImplementation(execute),
|
apply: jest.fn(execute),
|
||||||
applyWithGuard: jest.genMockFunction().mockImplementation(execute),
|
applyWithGuard: jest.fn(execute),
|
||||||
guard: jest.genMockFunction().mockImplementation(callback => callback),
|
guard: jest.fn(callback => callback),
|
||||||
inGuard: jest.genMockFunction().mockReturnValue(true),
|
inGuard: jest.fn().mockReturnValue(true),
|
||||||
reportError: jest.genMockFunction().mockImplementation(reportError),
|
reportError: jest.fn(reportError),
|
||||||
setGlobalHandler: jest.genMockFunction(),
|
setGlobalHandler: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = ErrorUtils;
|
module.exports = ErrorUtils;
|
||||||
|
|
|
@ -5,20 +5,14 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const PixelRatio = {
|
const PixelRatio = {
|
||||||
get: jest.genMockFunction().mockReturnValue(2),
|
get: jest.fn().mockReturnValue(2),
|
||||||
getFontScale: jest.genMockFunction().mockImplementation(
|
getFontScale: jest.fn(() => PixelRatio.get()),
|
||||||
() => PixelRatio.get()
|
getPixelSizeForLayoutSize: jest.fn(layoutSize => Math.round(layoutSize * PixelRatio.get())),
|
||||||
),
|
roundToNearestPixel: jest.fn(layoutSize => {
|
||||||
getPixelSizeForLayoutSize: jest.genMockFunction().mockImplementation(
|
|
||||||
layoutSize => Math.round(layoutSize * PixelRatio.get())
|
|
||||||
),
|
|
||||||
roundToNearestPixel: jest.genMockFunction().mockImplementation(
|
|
||||||
layoutSize => {
|
|
||||||
const ratio = PixelRatio.get();
|
const ratio = PixelRatio.get();
|
||||||
return Math.round(layoutSize * ratio) / ratio;
|
return Math.round(layoutSize * ratio) / ratio;
|
||||||
}
|
}),
|
||||||
),
|
startDetecting: jest.fn(),
|
||||||
startDetecting: jest.genMockFunction(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = PixelRatio;
|
module.exports = PixelRatio;
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('MatrixMath');
|
jest.unmock('MatrixMath');
|
||||||
jest.dontMock('fbjs/lib/invariant');
|
jest.unmock('fbjs/lib/invariant');
|
||||||
|
|
||||||
var MatrixMath = require('MatrixMath');
|
var MatrixMath = require('MatrixMath');
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('MessageQueue')
|
jest.unmock('MessageQueue')
|
||||||
.dontMock('fbjs/lib/keyMirror');
|
.unmock('fbjs/lib/keyMirror');
|
||||||
var MessageQueue = require('MessageQueue');
|
var MessageQueue = require('MessageQueue');
|
||||||
|
|
||||||
let MODULE_IDS = 0;
|
let MODULE_IDS = 0;
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('../Platform.ios');
|
jest.unmock('../Platform.ios');
|
||||||
jest.dontMock('../Platform.android');
|
jest.unmock('../Platform.android');
|
||||||
|
|
||||||
var PlatformIOS = require('../Platform.ios');
|
var PlatformIOS = require('../Platform.ios');
|
||||||
var PlatformAndroid = require('../Platform.android');
|
var PlatformAndroid = require('../Platform.android');
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
const {encode} = require('../utf8');
|
const {encode} = require('../utf8');
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('deepDiffer');
|
jest.unmock('deepDiffer');
|
||||||
var deepDiffer = require('deepDiffer');
|
var deepDiffer = require('deepDiffer');
|
||||||
|
|
||||||
describe('deepDiffer', function() {
|
describe('deepDiffer', function() {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('WebSocket');
|
jest.unmock('WebSocket');
|
||||||
jest.setMock('NativeModules', {
|
jest.setMock('NativeModules', {
|
||||||
WebSocketModule: {
|
WebSocketModule: {
|
||||||
connect: () => {}
|
connect: () => {}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
var Activity = require('../');
|
var Activity = require('../');
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ describe('Activity', () => {
|
||||||
const origConsoleLog = console.log;
|
const origConsoleLog = console.log;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
console.log = jest.genMockFn();
|
console.log = jest.fn();
|
||||||
jest.runOnlyPendingTimers();
|
jest.runOnlyPendingTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.mock('crypto')
|
.mock('crypto')
|
||||||
|
@ -199,8 +199,8 @@ describe('AssetServer', () => {
|
||||||
describe('assetServer.getAssetData', () => {
|
describe('assetServer.getAssetData', () => {
|
||||||
pit('should get assetData', () => {
|
pit('should get assetData', () => {
|
||||||
const hash = {
|
const hash = {
|
||||||
update: jest.genMockFn(),
|
update: jest.fn(),
|
||||||
digest: jest.genMockFn(),
|
digest: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
hash.digest.mockImpl(() => 'wow such hash');
|
hash.digest.mockImpl(() => 'wow such hash');
|
||||||
|
@ -241,8 +241,8 @@ describe('AssetServer', () => {
|
||||||
|
|
||||||
pit('should get assetData for non-png images', () => {
|
pit('should get assetData for non-png images', () => {
|
||||||
const hash = {
|
const hash = {
|
||||||
update: jest.genMockFn(),
|
update: jest.fn(),
|
||||||
digest: jest.genMockFn(),
|
digest: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
hash.digest.mockImpl(() => 'wow such hash');
|
hash.digest.mockImpl(() => 'wow such hash');
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
const Bundle = require('../Bundle');
|
const Bundle = require('../Bundle');
|
||||||
const ModuleTransport = require('../../lib/ModuleTransport');
|
const ModuleTransport = require('../../lib/ModuleTransport');
|
||||||
|
@ -21,7 +21,7 @@ describe('Bundle', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
bundle = new Bundle({sourceMapUrl: 'test_url'});
|
bundle = new Bundle({sourceMapUrl: 'test_url'});
|
||||||
bundle.getSourceMap = jest.genMockFn().mockImpl(() => {
|
bundle.getSourceMap = jest.fn(() => {
|
||||||
return 'test-source-map';
|
return 'test-source-map';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.setMock('worker-farm', () => () => undefined)
|
.setMock('worker-farm', () => () => undefined)
|
||||||
|
@ -68,8 +68,8 @@ describe('Bundler', function() {
|
||||||
var projectRoots;
|
var projectRoots;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
getDependencies = jest.genMockFn();
|
getDependencies = jest.fn();
|
||||||
getModuleSystemDependencies = jest.genMockFn();
|
getModuleSystemDependencies = jest.fn();
|
||||||
projectRoots = ['/root'];
|
projectRoots = ['/root'];
|
||||||
|
|
||||||
Resolver.mockImpl(function() {
|
Resolver.mockImpl(function() {
|
||||||
|
@ -90,7 +90,7 @@ describe('Bundler', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
assetServer = {
|
assetServer = {
|
||||||
getAssetData: jest.genMockFn(),
|
getAssetData: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
bundler = new Bundler({
|
bundler = new Bundler({
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest
|
jest
|
||||||
.dontMock('../../lib/ModuleTransport')
|
.unmock('../../lib/ModuleTransport')
|
||||||
.dontMock('../');
|
.unmock('../');
|
||||||
|
|
||||||
const fs = {writeFileSync: jest.genMockFn()};
|
const fs = {writeFileSync: jest.fn()};
|
||||||
const temp = {path: () => '/arbitrary/path'};
|
const temp = {path: () => '/arbitrary/path'};
|
||||||
const workerFarm = jest.genMockFn();
|
const workerFarm = jest.fn();
|
||||||
jest.setMock('fs', fs);
|
jest.setMock('fs', fs);
|
||||||
jest.setMock('temp', temp);
|
jest.setMock('temp', temp);
|
||||||
jest.setMock('worker-farm', workerFarm);
|
jest.setMock('worker-farm', workerFarm);
|
||||||
|
@ -29,15 +29,15 @@ describe('Transformer', function() {
|
||||||
const transformModulePath = __filename;
|
const transformModulePath = __filename;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
Cache = jest.genMockFn();
|
Cache = jest.fn();
|
||||||
Cache.prototype.get = jest.genMockFn().mockImpl((a, b, c) => c());
|
Cache.prototype.get = jest.fn((a, b, c) => c());
|
||||||
|
|
||||||
fs.writeFileSync.mockClear();
|
fs.writeFileSync.mockClear();
|
||||||
options = {transformModulePath};
|
options = {transformModulePath};
|
||||||
workerFarm.mockClear();
|
workerFarm.mockClear();
|
||||||
workerFarm.mockImpl((opts, path, methods) => {
|
workerFarm.mockImpl((opts, path, methods) => {
|
||||||
const api = workers = {};
|
const api = workers = {};
|
||||||
methods.forEach(method => api[method] = jest.genMockFn());
|
methods.forEach(method => api[method] = jest.fn());
|
||||||
return api;
|
return api;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
const babel = require('babel-core');
|
const babel = require('babel-core');
|
||||||
const constantFolding = require('../constant-folding');
|
const constantFolding = require('../constant-folding');
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
const extractDependencies = require('../extract-dependencies');
|
const extractDependencies = require('../extract-dependencies');
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
const inline = require('../inline');
|
const inline = require('../inline');
|
||||||
const {transform, transformFromAst} = require('babel-core');
|
const {transform, transformFromAst} = require('babel-core');
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
const uglify = {
|
const uglify = {
|
||||||
minify: jest.genMockFunction().mockImplementation(code => {
|
minify: jest.fn(code => {
|
||||||
return {
|
return {
|
||||||
code: code.replace(/(^|\W)\s+/g, '$1'),
|
code: code.replace(/(^|\W)\s+/g, '$1'),
|
||||||
map: {},
|
map: {},
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
jest.mock('../constant-folding');
|
jest.mock('../constant-folding');
|
||||||
jest.mock('../extract-dependencies');
|
jest.mock('../extract-dependencies');
|
||||||
jest.mock('../inline');
|
jest.mock('../inline');
|
||||||
|
@ -22,7 +22,7 @@ describe('code transformation worker:', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
extractDependencies =
|
extractDependencies =
|
||||||
require('../extract-dependencies').mockReturnValue({});
|
require('../extract-dependencies').mockReturnValue({});
|
||||||
transform = jest.genMockFunction();
|
transform = jest.fn();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls the transform with file name, source code, and transform options', function() {
|
it('calls the transform with file name, source code, and transform options', function() {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.dontMock('../');
|
jest.unmock('../');
|
||||||
jest.mock('path');
|
jest.mock('path');
|
||||||
|
|
||||||
const Promise = require('promise');
|
const Promise = require('promise');
|
||||||
|
@ -16,7 +16,7 @@ const Resolver = require('../');
|
||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
let DependencyGraph = jest.genMockFn();
|
let DependencyGraph = jest.fn();
|
||||||
jest.setMock('node-haste', DependencyGraph);
|
jest.setMock('node-haste', DependencyGraph);
|
||||||
let Module;
|
let Module;
|
||||||
let Polyfill;
|
let Polyfill;
|
||||||
|
@ -24,26 +24,26 @@ let Polyfill;
|
||||||
describe('Resolver', function() {
|
describe('Resolver', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
DependencyGraph.mockClear();
|
DependencyGraph.mockClear();
|
||||||
Module = jest.genMockFn().mockImpl(function() {
|
Module = jest.fn(function() {
|
||||||
this.getName = jest.genMockFn();
|
this.getName = jest.fn();
|
||||||
this.getDependencies = jest.genMockFn();
|
this.getDependencies = jest.fn();
|
||||||
this.isPolyfill = jest.genMockFn().mockReturnValue(false);
|
this.isPolyfill = jest.fn().mockReturnValue(false);
|
||||||
this.isJSON = jest.genMockFn().mockReturnValue(false);
|
this.isJSON = jest.fn().mockReturnValue(false);
|
||||||
});
|
});
|
||||||
Polyfill = jest.genMockFn().mockImpl(function() {
|
Polyfill = jest.fn(function() {
|
||||||
var polyfill = new Module();
|
var polyfill = new Module();
|
||||||
polyfill.isPolyfill.mockReturnValue(true);
|
polyfill.isPolyfill.mockReturnValue(true);
|
||||||
return polyfill;
|
return polyfill;
|
||||||
});
|
});
|
||||||
|
|
||||||
DependencyGraph.replacePatterns = require.requireActual('node-haste/lib/lib/replacePatterns');
|
DependencyGraph.replacePatterns = require.requireActual('node-haste/lib/lib/replacePatterns');
|
||||||
DependencyGraph.prototype.createPolyfill = jest.genMockFn();
|
DependencyGraph.prototype.createPolyfill = jest.fn();
|
||||||
DependencyGraph.prototype.getDependencies = jest.genMockFn();
|
DependencyGraph.prototype.getDependencies = jest.fn();
|
||||||
|
|
||||||
// For the polyfillDeps
|
// For the polyfillDeps
|
||||||
path.join = jest.genMockFn().mockImpl((a, b) => b);
|
path.join = jest.fn((a, b) => b);
|
||||||
|
|
||||||
DependencyGraph.prototype.load = jest.genMockFn().mockImpl(() => Promise.resolve());
|
DependencyGraph.prototype.load = jest.fn(() => Promise.resolve());
|
||||||
});
|
});
|
||||||
|
|
||||||
class ResolutionResponseMock {
|
class ResolutionResponseMock {
|
||||||
|
@ -81,9 +81,9 @@ describe('Resolver', function() {
|
||||||
|
|
||||||
function createPolyfill(id, dependencies) {
|
function createPolyfill(id, dependencies) {
|
||||||
var polyfill = new Polyfill({});
|
var polyfill = new Polyfill({});
|
||||||
polyfill.getName = jest.genMockFn().mockImpl(() => Promise.resolve(id));
|
polyfill.getName = jest.fn(() => Promise.resolve(id));
|
||||||
polyfill.getDependencies =
|
polyfill.getDependencies =
|
||||||
jest.genMockFn().mockImpl(() => Promise.resolve(dependencies));
|
jest.fn(() => Promise.resolve(dependencies));
|
||||||
return polyfill;
|
return polyfill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ describe('Resolver', function() {
|
||||||
let depResolver, minifyCode, module, resolutionResponse, sourceMap;
|
let depResolver, minifyCode, module, resolutionResponse, sourceMap;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
minifyCode = jest.genMockFn().mockImpl((filename, code, map) =>
|
minifyCode = jest.fn((filename, code, map) =>
|
||||||
Promise.resolve({code, map}));
|
Promise.resolve({code, map}));
|
||||||
depResolver = new Resolver({
|
depResolver = new Resolver({
|
||||||
projectRoot: '/root',
|
projectRoot: '/root',
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
* @emails oncall+jsinfra
|
* @emails oncall+jsinfra
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
describe('Number (ES6)', () => {
|
describe('Number (ES6)', () => {
|
||||||
describe('EPSILON', () => {
|
describe('EPSILON', () => {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
/* eslint-disable fb-www/object-create-only-one-param */
|
/* eslint-disable fb-www/object-create-only-one-param */
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
describe('Object (ES7)', () => {
|
describe('Object (ES7)', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
jest.setMock('worker-farm', function() { return () => {}; })
|
jest.setMock('worker-farm', function() { return () => {}; })
|
||||||
.setMock('timers', { setImmediate: (fn) => setTimeout(fn, 0) })
|
.setMock('timers', { setImmediate: (fn) => setTimeout(fn, 0) })
|
||||||
|
@ -54,20 +54,19 @@ describe('processRequest', () => {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const invalidatorFunc = jest.genMockFunction();
|
const invalidatorFunc = jest.fn();
|
||||||
const watcherFunc = jest.genMockFunction();
|
const watcherFunc = jest.fn();
|
||||||
var requestHandler;
|
var requestHandler;
|
||||||
var triggerFileChange;
|
var triggerFileChange;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
FileWatcher = require('node-haste').FileWatcher;
|
FileWatcher = require('node-haste').FileWatcher;
|
||||||
Bundler.prototype.bundle = jest.genMockFunction().mockImpl(() =>
|
Bundler.prototype.bundle = jest.fn(() =>
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
getSource: () => 'this is the source',
|
getSource: () => 'this is the source',
|
||||||
getSourceMap: () => 'this is the source map',
|
getSourceMap: () => 'this is the source map',
|
||||||
getEtag: () => 'this is an etag',
|
getEtag: () => 'this is an etag',
|
||||||
})
|
}));
|
||||||
);
|
|
||||||
|
|
||||||
FileWatcher.prototype.on = function(eventType, callback) {
|
FileWatcher.prototype.on = function(eventType, callback) {
|
||||||
if (eventType !== 'all') {
|
if (eventType !== 'all') {
|
||||||
|
@ -198,7 +197,7 @@ describe('processRequest', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not rebuild the bundles that contain a file when that file is changed', () => {
|
it('does not rebuild the bundles that contain a file when that file is changed', () => {
|
||||||
const bundleFunc = jest.genMockFunction();
|
const bundleFunc = jest.fn();
|
||||||
bundleFunc
|
bundleFunc
|
||||||
.mockReturnValueOnce(
|
.mockReturnValueOnce(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
|
@ -243,7 +242,7 @@ describe('processRequest', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not rebuild the bundles that contain a file when that file is changed, even when hot loading is enabled', () => {
|
it('does not rebuild the bundles that contain a file when that file is changed, even when hot loading is enabled', () => {
|
||||||
const bundleFunc = jest.genMockFunction();
|
const bundleFunc = jest.fn();
|
||||||
bundleFunc
|
bundleFunc
|
||||||
.mockReturnValueOnce(
|
.mockReturnValueOnce(
|
||||||
Promise.resolve({
|
Promise.resolve({
|
||||||
|
@ -301,8 +300,8 @@ describe('processRequest', () => {
|
||||||
req = new EventEmitter();
|
req = new EventEmitter();
|
||||||
req.url = '/onchange';
|
req.url = '/onchange';
|
||||||
res = {
|
res = {
|
||||||
writeHead: jest.genMockFn(),
|
writeHead: jest.fn(),
|
||||||
end: jest.genMockFn()
|
end: jest.fn()
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -326,7 +325,7 @@ describe('processRequest', () => {
|
||||||
describe('/assets endpoint', () => {
|
describe('/assets endpoint', () => {
|
||||||
it('should serve simple case', () => {
|
it('should serve simple case', () => {
|
||||||
const req = {url: '/assets/imgs/a.png'};
|
const req = {url: '/assets/imgs/a.png'};
|
||||||
const res = {end: jest.genMockFn()};
|
const res = {end: jest.fn()};
|
||||||
|
|
||||||
AssetServer.prototype.get.mockImpl(() => Promise.resolve('i am image'));
|
AssetServer.prototype.get.mockImpl(() => Promise.resolve('i am image'));
|
||||||
|
|
||||||
|
@ -337,7 +336,7 @@ describe('processRequest', () => {
|
||||||
|
|
||||||
it('should parse the platform option', () => {
|
it('should parse the platform option', () => {
|
||||||
const req = {url: '/assets/imgs/a.png?platform=ios'};
|
const req = {url: '/assets/imgs/a.png?platform=ios'};
|
||||||
const res = {end: jest.genMockFn()};
|
const res = {end: jest.fn()};
|
||||||
|
|
||||||
AssetServer.prototype.get.mockImpl(() => Promise.resolve('i am image'));
|
AssetServer.prototype.get.mockImpl(() => Promise.resolve('i am image'));
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
jest.autoMockOff();
|
jest.disableAutomock();
|
||||||
|
|
||||||
var declareOpts = require('../declareOpts');
|
var declareOpts = require('../declareOpts');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue