@@ -7,111 +7,124 @@ const {
7
7
isCustomComponent
8
8
} = require ( '../lib/utilities' ) ;
9
9
10
- describe ( 'utilties.camelCase' , ( ) => {
11
- [ undefined , null , 1337 , { } , [ ] ] . forEach ( value => {
12
- it ( `throws an error if first argument is ${ value } ` , ( ) => {
13
- assert . throws ( ( ) => {
14
- camelCase ( value ) ;
15
- } , TypeError ) ;
10
+ describe ( 'utilities' , ( ) => {
11
+ describe ( 'camelCase' , ( ) => {
12
+ [ undefined , null , 1337 , { } , [ ] ] . forEach ( value => {
13
+ it ( `throws an error if first argument is ${ value } ` , ( ) => {
14
+ assert . throws ( ( ) => {
15
+ camelCase ( value ) ;
16
+ } , TypeError ) ;
17
+ } ) ;
16
18
} ) ;
17
- } ) ;
18
-
19
- it ( 'does not modify string if it does not need to be camelCased' , ( ) => {
20
- assert . equal ( camelCase ( '' ) , '' ) ;
21
- assert . equal ( camelCase ( 'foo' ) , 'foo' ) ;
22
- assert . equal ( camelCase ( 'fooBar' ) , 'fooBar' ) ;
23
- assert . equal ( camelCase ( '--fooBar' ) , '--fooBar' ) ;
24
- assert . equal ( camelCase ( '--foo-bar' ) , '--foo-bar' ) ;
25
- assert . equal ( camelCase ( '--foo100' ) , '--foo100' ) ;
26
- assert . equal ( camelCase ( '--foo-100' ) , '--foo-100' ) ;
27
- } ) ;
28
19
29
- it ( 'camelCases a string' , ( ) => {
30
- assert . equal ( camelCase ( 'foo-bar' ) , 'fooBar' ) ;
31
- assert . equal ( camelCase ( 'foo-bar-baz' ) , 'fooBarBaz' ) ;
32
- assert . equal ( camelCase ( 'CAMEL-CASE' ) , 'camelCase' ) ;
33
- } ) ;
34
- } ) ;
20
+ it ( 'does not modify string if it does not need to be camelCased' , ( ) => {
21
+ [
22
+ [ '' , '' ] ,
23
+ [ 'foo' , 'foo' ] ,
24
+ [ 'fooBar' , 'fooBar' ] ,
25
+ [ '--fooBar' , '--fooBar' ] ,
26
+ [ '--foo-bar' , '--foo-bar' ] ,
27
+ [ '--foo-100' , '--foo-100' ]
28
+ ] . forEach ( testCase => {
29
+ assert . strictEqual ( camelCase ( testCase [ 0 ] ) , testCase [ 1 ] ) ;
30
+ } ) ;
31
+ } ) ;
35
32
36
- describe ( 'utilities.invertObject' , ( ) => {
37
- [ undefined , null , 'foo' , 1337 ] . forEach ( value => {
38
- it ( `throws an error if the first argument is ${ value } ` , ( ) => {
39
- assert . throws ( ( ) => {
40
- invertObject ( value ) ;
41
- } , TypeError ) ;
33
+ it ( 'camelCases a string' , ( ) => {
34
+ [
35
+ [ 'foo-bar' , 'fooBar' ] ,
36
+ [ 'foo-bar-baz' , 'fooBarBaz' ] ,
37
+ [ 'CAMEL-CASE' , 'camelCase' ]
38
+ ] . forEach ( testCase => {
39
+ assert . strictEqual ( camelCase ( testCase [ 0 ] ) , testCase [ 1 ] ) ;
40
+ } ) ;
42
41
} ) ;
43
42
} ) ;
44
43
45
- it ( 'swaps key with value' , ( ) => {
46
- assert . deepEqual ( invertObject ( { foo : 'bar' , baz : 'qux' } ) , {
47
- bar : 'foo' ,
48
- qux : 'baz'
44
+ describe ( 'invertObject' , ( ) => {
45
+ [ undefined , null , 'foo' , 1337 ] . forEach ( value => {
46
+ it ( `throws an error if the first argument is ${ value } ` , ( ) => {
47
+ assert . throws ( ( ) => {
48
+ invertObject ( value ) ;
49
+ } , TypeError ) ;
50
+ } ) ;
49
51
} ) ;
50
- } ) ;
51
52
52
- it ( 'swaps key with value if value is string' , ( ) => {
53
- assert . deepEqual (
54
- invertObject ( {
55
- $ : 'dollar' ,
56
- _ : 'underscore' ,
57
- num : 1 ,
58
- u : undefined ,
59
- n : null
60
- } ) ,
61
- {
62
- dollar : '$' ,
63
- underscore : '_'
64
- }
65
- ) ;
66
- } ) ;
53
+ it ( 'swaps key with value' , ( ) => {
54
+ assert . deepEqual ( invertObject ( { foo : 'bar' , baz : 'qux' } ) , {
55
+ bar : 'foo' ,
56
+ qux : 'baz'
57
+ } ) ;
58
+ } ) ;
67
59
68
- describe ( 'options' , ( ) => {
69
- it ( 'applies override if provided' , ( ) => {
60
+ it ( 'swaps key with value if value is string' , ( ) => {
70
61
assert . deepEqual (
71
- invertObject ( { foo : 'bar' , baz : 'qux' } , key => {
72
- if ( key === 'foo' ) {
73
- return [ 'key' , 'value' ] ;
74
- }
62
+ invertObject ( {
63
+ $ : 'dollar' ,
64
+ _ : 'underscore' ,
65
+ num : 1 ,
66
+ u : undefined ,
67
+ n : null
75
68
} ) ,
76
- { key : 'value' , qux : 'baz' }
69
+ {
70
+ dollar : '$' ,
71
+ underscore : '_'
72
+ }
77
73
) ;
78
74
} ) ;
79
75
80
- it ( 'does not apply override if invalid' , ( ) => {
81
- assert . deepEqual (
82
- invertObject ( { foo : 'bar' , baz : 'qux' } , key => {
83
- if ( key === 'foo' ) {
84
- return [ 'key' ] ;
85
- } else if ( key === 'baz' ) {
86
- return { key : 'value' } ;
87
- }
88
- } ) ,
89
- { bar : 'foo' , qux : 'baz' }
90
- ) ;
76
+ describe ( 'options' , ( ) => {
77
+ it ( 'applies override if provided' , ( ) => {
78
+ assert . deepEqual (
79
+ invertObject ( { foo : 'bar' , baz : 'qux' } , key => {
80
+ if ( key === 'foo' ) {
81
+ return [ 'key' , 'value' ] ;
82
+ }
83
+ } ) ,
84
+ { key : 'value' , qux : 'baz' }
85
+ ) ;
86
+ } ) ;
87
+
88
+ it ( 'does not apply override if invalid' , ( ) => {
89
+ assert . deepEqual (
90
+ invertObject ( { foo : 'bar' , baz : 'qux' } , key => {
91
+ if ( key === 'foo' ) {
92
+ return [ 'key' ] ;
93
+ } else if ( key === 'baz' ) {
94
+ return { key : 'value' } ;
95
+ }
96
+ } ) ,
97
+ { bar : 'foo' , qux : 'baz' }
98
+ ) ;
99
+ } ) ;
91
100
} ) ;
92
101
} ) ;
93
- } ) ;
94
102
95
- describe ( 'utilities. isCustomComponent' , ( ) => {
96
- it ( 'returns true if the tag contains a hyphen and is not in the whitelist' , ( ) => {
97
- assert . equal ( isCustomComponent ( 'my-custom-element' ) , true ) ;
98
- } ) ;
103
+ describe ( 'isCustomComponent' , ( ) => {
104
+ it ( 'returns true if the tag contains a hyphen and is not in the whitelist' , ( ) => {
105
+ assert . strictEqual ( isCustomComponent ( 'my-custom-element' ) , true ) ;
106
+ } ) ;
99
107
100
- it ( 'returns false if the tag is in the whitelist' , ( ) => {
101
- assert . equal ( isCustomComponent ( 'annotation-xml' ) , false ) ;
102
- assert . equal ( isCustomComponent ( 'color-profile' ) , false ) ;
103
- assert . equal ( isCustomComponent ( 'font-face' ) , false ) ;
104
- } ) ;
108
+ it ( 'returns false if the tag is in the whitelist' , ( ) => {
109
+ assert . strictEqual ( isCustomComponent ( 'annotation-xml' ) , false ) ;
110
+ assert . strictEqual ( isCustomComponent ( 'color-profile' ) , false ) ;
111
+ assert . strictEqual ( isCustomComponent ( 'font-face' ) , false ) ;
112
+ } ) ;
105
113
106
- it ( 'returns true if the props contains an `is` key' , ( ) => {
107
- assert . equal ( isCustomComponent ( 'button' , { is : 'custom-button' } ) , true ) ;
114
+ it ( 'returns true if the props contains an `is` key' , ( ) => {
115
+ assert . strictEqual (
116
+ isCustomComponent ( 'button' , { is : 'custom-button' } ) ,
117
+ true
118
+ ) ;
119
+ } ) ;
108
120
} ) ;
109
- } ) ;
110
121
111
- describe ( 'utilities.PRESERVE_CUSTOM_ATTRIBUTES' , ( ) => {
112
- const isReact16AndUp = Number ( React . version . match ( / ^ \d ./ ) [ 0 ] ) >= 16 ;
122
+ describe ( 'PRESERVE_CUSTOM_ATTRIBUTES' , ( ) => {
123
+ const isReactGreaterThan15 =
124
+ parseInt ( React . version . match ( / ^ \d ./ ) [ 0 ] , 10 ) >= 16 ;
113
125
114
- it ( `is ${ isReact16AndUp } when React.version="${ React . version } "` , ( ) => {
115
- assert . equal ( PRESERVE_CUSTOM_ATTRIBUTES , isReact16AndUp ) ;
126
+ it ( `is ${ isReactGreaterThan15 } when React.version="${ React . version } "` , ( ) => {
127
+ assert . strictEqual ( PRESERVE_CUSTOM_ATTRIBUTES , isReactGreaterThan15 ) ;
128
+ } ) ;
116
129
} ) ;
117
130
} ) ;
0 commit comments