Skip to content

Commit 79902f9

Browse files
elicwhitefacebook-github-bot
authored andcommitted
Finish migration from jasmine to jest
Reviewed By: cpojer Differential Revision: D6671373 fbshipit-source-id: e9570b9a9da6063576905719f7ffc5465cda737a
1 parent 9c67e74 commit 79902f9

File tree

4 files changed

+64
-64
lines changed

4 files changed

+64
-64
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
"env": {
1111
"es6": true,
12-
"jasmine": true,
12+
"jest": true,
1313
},
1414

1515
"plugins": [

Libraries/Animated/src/__tests__/AnimatedNative-test.js

+54-54
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('Native Animated', () => {
8080

8181
anim.setValue(0.5);
8282

83-
expect(nativeAnimatedModule.setAnimatedNodeValue).toBeCalledWith(jasmine.any(Number), 0.5);
83+
expect(nativeAnimatedModule.setAnimatedNodeValue).toBeCalledWith(expect.any(Number), 0.5);
8484
expect(c.refs.node.setNativeProps).not.toHaveBeenCalled();
8585
});
8686

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

9797
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
98-
jasmine.any(Number),
98+
expect.any(Number),
9999
{type: 'value', value: 0, offset: 10},
100100
);
101101
anim.setOffset(20);
102102
expect(nativeAnimatedModule.setAnimatedNodeOffset)
103-
.toBeCalledWith(jasmine.any(Number), 20);
103+
.toBeCalledWith(expect.any(Number), 20);
104104
});
105105

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

115115
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
116-
jasmine.any(Number),
116+
expect.any(Number),
117117
{type: 'value', value: 0, offset: 0},
118118
);
119119
anim.flattenOffset();
120120
expect(nativeAnimatedModule.flattenAnimatedNodeOffset)
121-
.toBeCalledWith(jasmine.any(Number));
121+
.toBeCalledWith(expect.any(Number));
122122
});
123123

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

133133
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
134-
jasmine.any(Number),
134+
expect.any(Number),
135135
{type: 'value', value: 0, offset: 0},
136136
);
137137
anim.extractOffset();
138138
expect(nativeAnimatedModule.extractAnimatedNodeOffset)
139-
.toBeCalledWith(jasmine.any(Number));
139+
.toBeCalledWith(expect.any(Number));
140140
});
141141
});
142142

@@ -214,14 +214,14 @@ describe('Native Animated', () => {
214214
);
215215
const c = createAndMountComponent(Animated.View, {onTouchMove: event});
216216
expect(nativeAnimatedModule.addAnimatedEventToView).toBeCalledWith(
217-
jasmine.any(Number),
217+
expect.any(Number),
218218
'onTouchMove',
219219
{nativeEventPath: ['state', 'foo'], animatedValueTag: value.__getNativeTag()},
220220
);
221221

222222
c.componentWillUnmount();
223223
expect(nativeAnimatedModule.removeAnimatedEventFromView).toBeCalledWith(
224-
jasmine.any(Number),
224+
expect.any(Number),
225225
'onTouchMove',
226226
value.__getNativeTag(),
227227
);
@@ -271,10 +271,10 @@ describe('Native Animated', () => {
271271
expect(nativeAnimatedModule.connectAnimatedNodes).toHaveBeenCalledTimes(2);
272272

273273
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
274-
jasmine.any(Number),
275-
jasmine.any(Number),
276-
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number), iterations: 1},
277-
jasmine.any(Function)
274+
expect.any(Number),
275+
expect.any(Number),
276+
{type: 'frames', frames: expect.any(Array), toValue: expect.any(Number), iterations: 1},
277+
expect.any(Function)
278278
);
279279

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

294294
expect(nativeAnimatedModule.createAnimatedNode)
295-
.toBeCalledWith(jasmine.any(Number), {type: 'value', value: 0, offset: 0});
295+
.toBeCalledWith(expect.any(Number), {type: 'value', value: 0, offset: 0});
296296
expect(nativeAnimatedModule.createAnimatedNode)
297-
.toBeCalledWith(jasmine.any(Number), {type: 'style', style: {opacity: jasmine.any(Number)}});
297+
.toBeCalledWith(expect.any(Number), {type: 'style', style: {opacity: expect.any(Number)}});
298298
expect(nativeAnimatedModule.createAnimatedNode)
299-
.toBeCalledWith(jasmine.any(Number), {type: 'props', props: {style: jasmine.any(Number)}});
299+
.toBeCalledWith(expect.any(Number), {type: 'props', props: {style: expect.any(Number)}});
300300
});
301301

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

314314
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
315-
jasmine.any(Number),
316-
{type: 'addition', input: jasmine.any(Array)},
315+
expect.any(Number),
316+
{type: 'addition', input: expect.any(Array)},
317317
);
318318
const additionCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
319319
(call) => call[1].type === 'addition'
@@ -344,8 +344,8 @@ describe('Native Animated', () => {
344344
});
345345

346346
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
347-
jasmine.any(Number),
348-
{type: 'multiplication', input: jasmine.any(Array)},
347+
expect.any(Number),
348+
{type: 'multiplication', input: expect.any(Array)},
349349
);
350350
const multiplicationCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
351351
(call) => call[1].type === 'multiplication'
@@ -376,7 +376,7 @@ describe('Native Animated', () => {
376376
});
377377

378378
expect(nativeAnimatedModule.createAnimatedNode)
379-
.toBeCalledWith(jasmine.any(Number), {type: 'division', input: jasmine.any(Array)});
379+
.toBeCalledWith(expect.any(Number), {type: 'division', input: expect.any(Array)});
380380
const divisionCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
381381
(call) => call[1].type === 'division'
382382
);
@@ -404,8 +404,8 @@ describe('Native Animated', () => {
404404
});
405405

406406
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
407-
jasmine.any(Number),
408-
{type: 'modulus', modulus: 4, input: jasmine.any(Number)},
407+
expect.any(Number),
408+
{type: 'modulus', modulus: 4, input: expect.any(Number)},
409409
);
410410
const moduloCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
411411
(call) => call[1].type === 'modulus'
@@ -435,11 +435,11 @@ describe('Native Animated', () => {
435435
});
436436

437437
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
438-
jasmine.any(Number),
438+
expect.any(Number),
439439
{type: 'value', value: 10, offset: 0}
440440
);
441441
expect(nativeAnimatedModule.createAnimatedNode)
442-
.toBeCalledWith(jasmine.any(Number), {
442+
.toBeCalledWith(expect.any(Number), {
443443
type: 'interpolation',
444444
inputRange: [10, 20],
445445
outputRange: [0, 1],
@@ -466,11 +466,11 @@ describe('Native Animated', () => {
466466
});
467467

468468
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
469-
jasmine.any(Number),
469+
expect.any(Number),
470470
{
471471
type: 'transform',
472472
transforms: [{
473-
nodeTag: jasmine.any(Number),
473+
nodeTag: expect.any(Number),
474474
property: 'translateX',
475475
type: 'animated',
476476
}, {
@@ -493,8 +493,8 @@ describe('Native Animated', () => {
493493
});
494494

495495
expect(nativeAnimatedModule.createAnimatedNode).toBeCalledWith(
496-
jasmine.any(Number),
497-
{type: 'diffclamp', input: jasmine.any(Number), max: 20, min: 0},
496+
expect.any(Number),
497+
{type: 'diffclamp', input: expect.any(Number), max: 20, min: 0},
498498
);
499499
const diffClampCalls = nativeAnimatedModule.createAnimatedNode.mock.calls.filter(
500500
(call) => call[1].type === 'diffclamp'
@@ -570,9 +570,9 @@ describe('Native Animated', () => {
570570
});
571571

572572
expect(nativeAnimatedModule.createAnimatedNode)
573-
.toBeCalledWith(jasmine.any(Number), { type: 'style', style: { opacity: jasmine.any(Number) }});
573+
.toBeCalledWith(expect.any(Number), { type: 'style', style: { opacity: expect.any(Number) }});
574574
expect(nativeAnimatedModule.createAnimatedNode)
575-
.toBeCalledWith(jasmine.any(Number), { type: 'props', props: { style: jasmine.any(Number) }});
575+
.toBeCalledWith(expect.any(Number), { type: 'props', props: { style: expect.any(Number) }});
576576
});
577577
});
578578

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

584584
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
585-
jasmine.any(Number),
586-
jasmine.any(Number),
587-
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number), iterations: 1},
588-
jasmine.any(Function)
585+
expect.any(Number),
586+
expect.any(Number),
587+
{type: 'frames', frames: expect.any(Array), toValue: expect.any(Number), iterations: 1},
588+
expect.any(Function)
589589
);
590590
});
591591

592592
it('sends a valid spring animation description', () => {
593593
const anim = new Animated.Value(0);
594594
Animated.spring(anim, {toValue: 10, friction: 5, tension: 164, useNativeDriver: true}).start();
595595
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
596-
jasmine.any(Number),
597-
jasmine.any(Number),
596+
expect.any(Number),
597+
expect.any(Number),
598598
{
599599
type: 'spring',
600600
stiffness: 679.08,
@@ -607,7 +607,7 @@ describe('Native Animated', () => {
607607
toValue: 10,
608608
iterations: 1,
609609
},
610-
jasmine.any(Function)
610+
expect.any(Function)
611611
);
612612

613613
Animated.spring(anim, {
@@ -618,8 +618,8 @@ describe('Native Animated', () => {
618618
useNativeDriver: true
619619
}).start();
620620
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
621-
jasmine.any(Number),
622-
jasmine.any(Number),
621+
expect.any(Number),
622+
expect.any(Number),
623623
{
624624
type: 'spring',
625625
stiffness: 1000,
@@ -632,13 +632,13 @@ describe('Native Animated', () => {
632632
toValue: 10,
633633
iterations: 1,
634634
},
635-
jasmine.any(Function)
635+
expect.any(Function)
636636
);
637637

638638
Animated.spring(anim, {toValue: 10, bounciness: 8, speed: 10, useNativeDriver: true}).start();
639639
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
640-
jasmine.any(Number),
641-
jasmine.any(Number),
640+
expect.any(Number),
641+
expect.any(Number),
642642
{
643643
type: 'spring',
644644
damping: 23.05223140901191,
@@ -651,7 +651,7 @@ describe('Native Animated', () => {
651651
toValue: 10,
652652
iterations: 1,
653653
},
654-
jasmine.any(Function)
654+
expect.any(Function)
655655
);
656656
});
657657

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

662662
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
663-
jasmine.any(Number),
664-
jasmine.any(Number),
663+
expect.any(Number),
664+
expect.any(Number),
665665
{type: 'decay', deceleration: 0.1, velocity: 10, iterations: 1},
666-
jasmine.any(Function)
666+
expect.any(Function)
667667
);
668668
});
669669

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

677677
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
678-
jasmine.any(Number),
679-
jasmine.any(Number),
678+
expect.any(Number),
679+
expect.any(Number),
680680
{type: 'decay', deceleration: 0.1, velocity: 10, iterations: 10},
681-
jasmine.any(Function)
681+
expect.any(Function)
682682
);
683683
});
684684

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

689689
animation.start();
690690
expect(nativeAnimatedModule.startAnimatingNode).toBeCalledWith(
691-
jasmine.any(Number),
692-
jasmine.any(Number),
693-
{type: 'frames', frames: jasmine.any(Array), toValue: jasmine.any(Number), iterations: 1},
694-
jasmine.any(Function)
691+
expect.any(Number),
692+
expect.any(Number),
693+
{type: 'frames', frames: expect.any(Array), toValue: expect.any(Number), iterations: 1},
694+
expect.any(Function)
695695
);
696696
const animationId = nativeAnimatedModule.startAnimatingNode.mock.calls[0][0];
697697

Libraries/BatchedBridge/__tests__/MessageQueue-test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ describe('MessageQueue', function() {
5454
});
5555

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

6363
it('should store callbacks', () => {

Libraries/BatchedBridge/__tests__/NativeModules-test.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ describe('MessageQueue', function() {
5757
});
5858

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

6363
// Perform communication
6464
NativeModules.RemoteModule1.promiseMethod('paloAlto', 'menloPark', onFail, onSucc);
@@ -98,16 +98,16 @@ describe('MessageQueue', function() {
9898
expect(function() {
9999
BatchedBridge.__invokeCallback(firstSuccCBID, ['firstSucc']);
100100
}).toThrow();
101-
expect(onFail.calls.count()).toBe(1);
102-
expect(onSucc.calls.count()).toBe(0);
101+
expect(onFail.mock.calls.length).toBe(1);
102+
expect(onSucc.mock.calls.length).toBe(0);
103103

104104
// Handle the second remote invocation by signaling success.
105105
BatchedBridge.__invokeCallback(secondSuccCBID, ['secondSucc']);
106106
// The success callback was already invoked, the fail cb is no longer valid
107107
expect(function() {
108108
BatchedBridge.__invokeCallback(secondFailCBID, ['secondFail']);
109109
}).toThrow();
110-
expect(onFail.calls.count()).toBe(1);
111-
expect(onSucc.calls.count()).toBe(1);
110+
expect(onFail.mock.calls.length).toBe(1);
111+
expect(onSucc.mock.calls.length).toBe(1);
112112
});
113113
});

0 commit comments

Comments
 (0)