@@ -8,46 +8,47 @@ const {
8
8
9
9
describe ( 'utilities' , ( ) => {
10
10
describe ( 'camelCase' , ( ) => {
11
- [ undefined , null , 1337 , { } , [ ] ] . forEach ( value => {
12
- it ( `throws an error if first argument is ${ value } ` , ( ) => {
11
+ it . each ( [ undefined , null , { } , [ ] , 0 , 1 , ( ) => { } , new Date ( ) ] ) (
12
+ 'throws an error if first argument is %p' ,
13
+ input => {
13
14
expect ( ( ) => {
14
- camelCase ( value ) ;
15
+ camelCase ( input ) ;
15
16
} ) . toThrow ( TypeError ) ;
16
- } ) ;
17
- } ) ;
17
+ }
18
+ ) ;
18
19
19
- it ( 'does not modify string if it does not need to be camelCased' , ( ) => {
20
- [
21
- [ '' , '' ] ,
22
- [ 'foo' , 'foo' ] ,
23
- [ 'fooBar' , 'fooBar' ] ,
24
- [ '--fooBar' , '--fooBar' ] ,
25
- [ '--foo-bar' , '--foo-bar' ] ,
26
- [ '--foo-100' , '--foo-100' ]
27
- ] . forEach ( testCase => {
28
- expect ( camelCase ( testCase [ 0 ] ) ) . toBe ( testCase [ 1 ] ) ;
29
- } ) ;
30
- } ) ;
20
+ it . each ( [
21
+ [ '' , '' ] ,
22
+ [ 'foo' , 'foo' ] ,
23
+ [ 'fooBar' , 'fooBar' ] ,
24
+ [ '--fooBar' , '--fooBar' ] ,
25
+ [ '--foo-bar' , '--foo-bar' ] ,
26
+ [ '--foo-100' , '--foo-100' ]
27
+ ] ) (
28
+ 'does not modify string if it does not need to be camelCased' ,
29
+ ( input , expected ) => {
30
+ expect ( camelCase ( input ) ) . toBe ( expected ) ;
31
+ }
32
+ ) ;
31
33
32
- it ( 'camelCases a string' , ( ) => {
33
- [
34
- [ 'foo-bar' , 'fooBar' ] ,
35
- [ 'foo-bar-baz' , 'fooBarBaz' ] ,
36
- [ 'CAMEL-CASE' , 'camelCase' ]
37
- ] . forEach ( testCase => {
38
- expect ( camelCase ( testCase [ 0 ] ) ) . toBe ( testCase [ 1 ] ) ;
39
- } ) ;
34
+ it . each ( [
35
+ [ 'foo-bar' , 'fooBar' ] ,
36
+ [ 'foo-bar-baz' , 'fooBarBaz' ] ,
37
+ [ 'CAMEL-CASE' , 'camelCase' ]
38
+ ] ) ( 'camelCases a string' , ( input , expected ) => {
39
+ expect ( camelCase ( input ) ) . toBe ( expected ) ;
40
40
} ) ;
41
41
} ) ;
42
42
43
43
describe ( 'invertObject' , ( ) => {
44
- [ undefined , null , 'foo' , 1337 ] . forEach ( value => {
45
- it ( `throws an error if the first argument is ${ value } ` , ( ) => {
44
+ it . each ( [ undefined , null , 'string' , 0 , 1 , ( ) => { } ] ) (
45
+ `throws an error if the first argument is %p` ,
46
+ input => {
46
47
expect ( ( ) => {
47
- invertObject ( value ) ;
48
+ invertObject ( input ) ;
48
49
} ) . toThrow ( TypeError ) ;
49
- } ) ;
50
- } ) ;
50
+ }
51
+ ) ;
51
52
52
53
it ( 'swaps key with value' , ( ) => {
53
54
expect (
0 commit comments