1
- import forEach from 'jest-each' ;
2
-
3
1
import diff from './' ;
4
2
5
3
describe ( '.arrayDiff' , ( ) => {
6
4
7
5
describe ( 'base case' , ( ) => {
8
6
describe ( 'equal' , ( ) => {
9
- forEach ( [
7
+ test . each ( [
10
8
[ 'int' , 1 ] ,
11
9
[ 'string' , 'a' ] ,
12
10
[ 'boolean' , true ] ,
@@ -17,13 +15,13 @@ describe('.arrayDiff', () => {
17
15
[ 'function' , ( ) => ( { } ) ] ,
18
16
[ 'date' , new Date ( ) ] ,
19
17
[ 'date with milliseconds' , new Date ( '2017-01-01T00:00:00.637Z' ) ] ,
20
- ] ) . test ( 'returns empty object when given values of type %s are equal' , ( type , value ) => {
18
+ ] ) ( 'returns empty object when given values of type %s are equal' , ( type , value ) => {
21
19
expect ( diff ( value , value ) ) . toEqual ( { } ) ;
22
20
} ) ;
23
21
} ) ;
24
22
25
23
describe ( 'not equal and not object' , ( ) => {
26
- forEach ( [
24
+ test . each ( [
27
25
[ 1 , 2 ] ,
28
26
[ 'a' , 'b' ] ,
29
27
[ true , false ] ,
@@ -37,7 +35,7 @@ describe('.arrayDiff', () => {
37
35
[ ( ) => ( { } ) , 100 ] ,
38
36
[ new Date ( '2017-01-01' ) , new Date ( '2017-01-02' ) ] ,
39
37
[ new Date ( '2017-01-01T00:00:00.636Z' ) , new Date ( '2017-01-01T00:00:00.637Z' ) ] ,
40
- ] ) . test ( 'returns right hand side value when different to left hand side value (%s, %s)' , ( lhs , rhs ) => {
38
+ ] ) ( 'returns right hand side value when different to left hand side value (%s, %s)' , ( lhs , rhs ) => {
41
39
expect ( diff ( lhs , rhs ) ) . toEqual ( rhs ) ;
42
40
} ) ;
43
41
} ) ;
@@ -100,7 +98,6 @@ describe('.arrayDiff', () => {
100
98
delete expected [ '0' ] ;
101
99
delete expected [ '1' ] ;
102
100
delete expected [ '2' ] ;
103
- // expected.forEach(console.log)
104
101
expect ( diff ( [ 1 , 2 , 3 ] , [ 1 , 2 , 3 , 9 ] ) ) . toEqual ( expected ) ;
105
102
} ) ;
106
103
} ) ;
0 commit comments