Skip to content

Commit

Permalink
Finish migration from jasmine to jest
Browse files Browse the repository at this point in the history
Reviewed By: cpojer

Differential Revision: D6671373

fbshipit-source-id: e9570b9a9da6063576905719f7ffc5465cda737a
  • Loading branch information
TheSavior authored and facebook-github-bot committed Jan 8, 2018
1 parent 9c67e74 commit 79902f9
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

"env": {
"es6": true,
"jasmine": true,
"jest": true,
},

"plugins": [
Expand Down
108 changes: 54 additions & 54 deletions Libraries/Animated/src/__tests__/AnimatedNative-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Native Animated', () => {

anim.setValue(0.5);

expect(nativeAnimatedModule.setAnimatedNodeValue).toBeCalledWith(jasmine.any(Number), 0.5);
expect(nativeAnimatedModule.setAnimatedNodeValue).toBeCalledWith(expect.any(Number), 0.5);
expect(c.refs.node.setNativeProps).not.toHaveBeenCalled();
});

Expand All @@ -95,12 +95,12 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
expect.any(Number),
{type: 'value', value: 0, offset: 10},
);
anim.setOffset(20);
expect(nativeAnimatedModule.setAnimatedNodeOffset)
.toBeCalledWith(jasmine.any(Number), 20);
.toBeCalledWith(expect.any(Number), 20);
});

it('should flatten offset', () => {
Expand All @@ -113,12 +113,12 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
expect.any(Number),
{type: 'value', value: 0, offset: 0},
);
anim.flattenOffset();
expect(nativeAnimatedModule.flattenAnimatedNodeOffset)
.toBeCalledWith(jasmine.any(Number));
.toBeCalledWith(expect.any(Number));
});

it('should extract offset', () => {
Expand All @@ -131,12 +131,12 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
expect.any(Number),
{type: 'value', value: 0, offset: 0},
);
anim.extractOffset();
expect(nativeAnimatedModule.extractAnimatedNodeOffset)
.toBeCalledWith(jasmine.any(Number));
.toBeCalledWith(expect.any(Number));
});
});

Expand Down Expand Up @@ -214,14 +214,14 @@ describe('Native Animated', () => {
);
const c = createAndMountComponent(Animated.View, {onTouchMove: event});
expect(nativeAnimatedModule.addAnimatedEventToView).toBeCalledWith(
jasmine.any(Number),
expect.any(Number),
'onTouchMove',
{nativeEventPath: ['state', 'foo'], animatedValueTag: value.__getNativeTag()},
);

c.componentWillUnmount();
expect(nativeAnimatedModule.removeAnimatedEventFromView).toBeCalledWith(
jasmine.any(Number),
expect.any(Number),
'onTouchMove',
value.__getNativeTag(),
);
Expand Down Expand Up @@ -271,10 +271,10 @@ describe('Native Animated', () => {
expect(nativeAnimatedModule.connectAnimatedNodes).toHaveBeenCalledTimes(2);

expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number), iterations: 1},
jasmine.any(Function)
expect.any(Number),
expect.any(Number),
{type: 'frames', frames: expect.any(Array), toValue: expect.any(Number), iterations: 1},
expect.any(Function)
);

expect(nativeAnimatedModule.disconnectAnimatedNodes).toHaveBeenCalledTimes(2);
Expand All @@ -292,11 +292,11 @@ describe('Native Animated', () => {
Animated.timing(anim, {toValue: 10, duration: 1000, useNativeDriver: true}).start();

expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), {type: 'value', value: 0, offset: 0});
.toBeCalledWith(expect.any(Number), {type: 'value', value: 0, offset: 0});
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), {type: 'style', style: {opacity: jasmine.any(Number)}});
.toBeCalledWith(expect.any(Number), {type: 'style', style: {opacity: expect.any(Number)}});
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), {type: 'props', props: {style: jasmine.any(Number)}});
.toBeCalledWith(expect.any(Number), {type: 'props', props: {style: expect.any(Number)}});
});

it('sends a valid graph description for Animated.add nodes', () => {
Expand All @@ -312,8 +312,8 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
{type: 'addition', input: jasmine.any(Array)},
expect.any(Number),
{type: 'addition', input: expect.any(Array)},
);
const additionCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
(call) => call[1].type === 'addition'
Expand Down Expand Up @@ -344,8 +344,8 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
{type: 'multiplication', input: jasmine.any(Array)},
expect.any(Number),
{type: 'multiplication', input: expect.any(Array)},
);
const multiplicationCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
(call) => call[1].type === 'multiplication'
Expand Down Expand Up @@ -376,7 +376,7 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), {type: 'division', input: jasmine.any(Array)});
.toBeCalledWith(expect.any(Number), {type: 'division', input: expect.any(Array)});
const divisionCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
(call) => call[1].type === 'division'
);
Expand Down Expand Up @@ -404,8 +404,8 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
{type: 'modulus', modulus: 4, input: jasmine.any(Number)},
expect.any(Number),
{type: 'modulus', modulus: 4, input: expect.any(Number)},
);
const moduloCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
(call) => call[1].type === 'modulus'
Expand Down Expand Up @@ -435,11 +435,11 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
expect.any(Number),
{type: 'value', value: 10, offset: 0}
);
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), {
.toBeCalledWith(expect.any(Number), {
type: 'interpolation',
inputRange: [10, 20],
outputRange: [0, 1],
Expand All @@ -466,11 +466,11 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
expect.any(Number),
{
type: 'transform',
transforms: [{
nodeTag: jasmine.any(Number),
nodeTag: expect.any(Number),
property: 'translateX',
type: 'animated',
}, {
Expand All @@ -493,8 +493,8 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
jasmine.any(Number),
{type: 'diffclamp', input: jasmine.any(Number), max: 20, min: 0},
expect.any(Number),
{type: 'diffclamp', input: expect.any(Number), max: 20, min: 0},
);
const diffClampCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
(call) => call[1].type === 'diffclamp'
Expand Down Expand Up @@ -570,9 +570,9 @@ describe('Native Animated', () => {
});

expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), { type: 'style', style: { opacity: jasmine.any(Number) }});
.toBeCalledWith(expect.any(Number), { type: 'style', style: { opacity: expect.any(Number) }});
expect(nativeAnimatedModule.createAnimatedNode)
.toBeCalledWith(jasmine.any(Number), { type: 'props', props: { style: jasmine.any(Number) }});
.toBeCalledWith(expect.any(Number), { type: 'props', props: { style: expect.any(Number) }});
});
});

Expand All @@ -582,19 +582,19 @@ describe('Native Animated', () => {
Animated.timing(anim, {toValue: 10, duration: 1000, useNativeDriver: true}).start();

expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number), iterations: 1},
jasmine.any(Function)
expect.any(Number),
expect.any(Number),
{type: 'frames', frames: expect.any(Array), toValue: expect.any(Number), iterations: 1},
expect.any(Function)
);
});

it('sends a valid spring animation description', () => {
const anim = new Animated.Value(0);
Animated.spring(anim, {toValue: 10, friction: 5, tension: 164, useNativeDriver: true}).start();
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
expect.any(Number),
expect.any(Number),
{
type: 'spring',
stiffness: 679.08,
Expand All @@ -607,7 +607,7 @@ describe('Native Animated', () => {
toValue: 10,
iterations: 1,
},
jasmine.any(Function)
expect.any(Function)
);

Animated.spring(anim, {
Expand All @@ -618,8 +618,8 @@ describe('Native Animated', () => {
useNativeDriver: true
}).start();
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
expect.any(Number),
expect.any(Number),
{
type: 'spring',
stiffness: 1000,
Expand All @@ -632,13 +632,13 @@ describe('Native Animated', () => {
toValue: 10,
iterations: 1,
},
jasmine.any(Function)
expect.any(Function)
);

Animated.spring(anim, {toValue: 10, bounciness: 8, speed: 10, useNativeDriver: true}).start();
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
expect.any(Number),
expect.any(Number),
{
type: 'spring',
damping: 23.05223140901191,
Expand All @@ -651,7 +651,7 @@ describe('Native Animated', () => {
toValue: 10,
iterations: 1,
},
jasmine.any(Function)
expect.any(Function)
);
});

Expand All @@ -660,10 +660,10 @@ describe('Native Animated', () => {
Animated.decay(anim, {velocity: 10, deceleration: 0.1, useNativeDriver: true}).start();

expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
expect.any(Number),
expect.any(Number),
{type: 'decay', deceleration: 0.1, velocity: 10, iterations: 1},
jasmine.any(Function)
expect.any(Function)
);
});

Expand All @@ -675,10 +675,10 @@ describe('Native Animated', () => {
).start();

expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
expect.any(Number),
expect.any(Number),
{type: 'decay', deceleration: 0.1, velocity: 10, iterations: 10},
jasmine.any(Function)
expect.any(Function)
);
});

Expand All @@ -688,10 +688,10 @@ describe('Native Animated', () => {

animation.start();
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
jasmine.any(Number),
jasmine.any(Number),
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number), iterations: 1},
jasmine.any(Function)
expect.any(Number),
expect.any(Number),
{type: 'frames', frames: expect.any(Array), toValue: expect.any(Number), iterations: 1},
expect.any(Function)
);
const animationId = nativeAnimatedModule.startAnimatingNode.mock.calls[0][0];

Expand Down
6 changes: 3 additions & 3 deletions Libraries/BatchedBridge/__tests__/MessageQueue-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ describe('MessageQueue', function() {
});

it('should call a local function with the function name', () => {
MessageQueueTestModule.testHook2 = jasmine.createSpy();
expect(MessageQueueTestModule.testHook2.calls.count()).toEqual(0);
MessageQueueTestModule.testHook2 = jest.fn();
expect(MessageQueueTestModule.testHook2.mock.calls.length).toEqual(0);
queue.__callFunction('MessageQueueTestModule', 'testHook2', [2]);
expect(MessageQueueTestModule.testHook2.calls.count()).toEqual(1);
expect(MessageQueueTestModule.testHook2.mock.calls.length).toEqual(1);
});

it('should store callbacks', () => {
Expand Down
12 changes: 6 additions & 6 deletions Libraries/BatchedBridge/__tests__/NativeModules-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ describe('MessageQueue', function() {
});

it('should make round trip and clear memory', function() {
const onFail = jasmine.createSpy();
const onSucc = jasmine.createSpy();
const onFail = jest.fn();
const onSucc = jest.fn();

// Perform communication
NativeModules.RemoteModule1.promiseMethod('paloAlto', 'menloPark', onFail, onSucc);
Expand Down Expand Up @@ -98,16 +98,16 @@ describe('MessageQueue', function() {
expect(function() {
BatchedBridge.__invokeCallback(firstSuccCBID, ['firstSucc']);
}).toThrow();
expect(onFail.calls.count()).toBe(1);
expect(onSucc.calls.count()).toBe(0);
expect(onFail.mock.calls.length).toBe(1);
expect(onSucc.mock.calls.length).toBe(0);

// Handle the second remote invocation by signaling success.
BatchedBridge.__invokeCallback(secondSuccCBID, ['secondSucc']);
// The success callback was already invoked, the fail cb is no longer valid
expect(function() {
BatchedBridge.__invokeCallback(secondFailCBID, ['secondFail']);
}).toThrow();
expect(onFail.calls.count()).toBe(1);
expect(onSucc.calls.count()).toBe(1);
expect(onFail.mock.calls.length).toBe(1);
expect(onSucc.mock.calls.length).toBe(1);
});
});

0 comments on commit 79902f9

Please sign in to comment.