1- const assert = require ( 'assert' ) ;
21const React = require ( 'react' ) ;
32const {
43 PRESERVE_CUSTOM_ATTRIBUTES ,
@@ -11,9 +10,9 @@ describe('utilities', () => {
1110 describe ( 'camelCase' , ( ) => {
1211 [ undefined , null , 1337 , { } , [ ] ] . forEach ( value => {
1312 it ( `throws an error if first argument is ${ value } ` , ( ) => {
14- assert . throws ( ( ) => {
13+ expect ( ( ) => {
1514 camelCase ( value ) ;
16- } , TypeError ) ;
15+ } ) . toThrow ( TypeError ) ;
1716 } ) ;
1817 } ) ;
1918
@@ -26,7 +25,7 @@ describe('utilities', () => {
2625 [ '--foo-bar' , '--foo-bar' ] ,
2726 [ '--foo-100' , '--foo-100' ]
2827 ] . forEach ( testCase => {
29- assert . strictEqual ( camelCase ( testCase [ 0 ] ) , testCase [ 1 ] ) ;
28+ expect ( camelCase ( testCase [ 0 ] ) ) . toBe ( testCase [ 1 ] ) ;
3029 } ) ;
3130 } ) ;
3231
@@ -36,86 +35,85 @@ describe('utilities', () => {
3635 [ 'foo-bar-baz' , 'fooBarBaz' ] ,
3736 [ 'CAMEL-CASE' , 'camelCase' ]
3837 ] . forEach ( testCase => {
39- assert . strictEqual ( camelCase ( testCase [ 0 ] ) , testCase [ 1 ] ) ;
38+ expect ( camelCase ( testCase [ 0 ] ) ) . toBe ( testCase [ 1 ] ) ;
4039 } ) ;
4140 } ) ;
4241 } ) ;
4342
4443 describe ( 'invertObject' , ( ) => {
4544 [ undefined , null , 'foo' , 1337 ] . forEach ( value => {
4645 it ( `throws an error if the first argument is ${ value } ` , ( ) => {
47- assert . throws ( ( ) => {
46+ expect ( ( ) => {
4847 invertObject ( value ) ;
49- } , TypeError ) ;
48+ } ) . toThrow ( TypeError ) ;
5049 } ) ;
5150 } ) ;
5251
5352 it ( 'swaps key with value' , ( ) => {
54- assert . deepEqual ( invertObject ( { foo : 'bar' , baz : 'qux' } ) , {
53+ expect (
54+ invertObject ( {
55+ foo : 'bar' ,
56+ baz : 'qux'
57+ } )
58+ ) . toEqual ( {
5559 bar : 'foo' ,
5660 qux : 'baz'
5761 } ) ;
5862 } ) ;
5963
6064 it ( 'swaps key with value if value is string' , ( ) => {
61- assert . deepEqual (
65+ expect (
6266 invertObject ( {
6367 $ : 'dollar' ,
6468 _ : 'underscore' ,
6569 num : 1 ,
6670 u : undefined ,
6771 n : null
68- } ) ,
69- {
70- dollar : '$' ,
71- underscore : '_'
72- }
73- ) ;
72+ } )
73+ ) . toEqual ( {
74+ dollar : '$' ,
75+ underscore : '_'
76+ } ) ;
7477 } ) ;
7578
7679 describe ( 'options' , ( ) => {
7780 it ( 'applies override if provided' , ( ) => {
78- assert . deepEqual (
81+ expect (
7982 invertObject ( { foo : 'bar' , baz : 'qux' } , key => {
8083 if ( key === 'foo' ) {
8184 return [ 'key' , 'value' ] ;
8285 }
83- } ) ,
84- { key : 'value' , qux : 'baz' }
85- ) ;
86+ } )
87+ ) . toEqual ( { key : 'value' , qux : 'baz' } ) ;
8688 } ) ;
8789
8890 it ( 'does not apply override if invalid' , ( ) => {
89- assert . deepEqual (
91+ expect (
9092 invertObject ( { foo : 'bar' , baz : 'qux' } , key => {
9193 if ( key === 'foo' ) {
9294 return [ 'key' ] ;
9395 } else if ( key === 'baz' ) {
9496 return { key : 'value' } ;
9597 }
96- } ) ,
97- { bar : 'foo' , qux : 'baz' }
98- ) ;
98+ } )
99+ ) . toEqual ( { bar : 'foo' , qux : 'baz' } ) ;
99100 } ) ;
100101 } ) ;
101102 } ) ;
102103
103104 describe ( 'isCustomComponent' , ( ) => {
104105 it ( 'returns true if the tag contains a hyphen and is not in the whitelist' , ( ) => {
105- assert . strictEqual ( isCustomComponent ( 'my-custom-element' ) , true ) ;
106+ expect ( isCustomComponent ( 'my-custom-element' ) ) . toBe ( true ) ;
106107 } ) ;
107108
108109 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 ) ;
110+ expect ( isCustomComponent ( 'annotation-xml' ) ) . toBe ( false ) ;
111+ expect ( isCustomComponent ( 'color-profile' ) ) . toBe ( false ) ;
112+ expect ( isCustomComponent ( 'font-face' ) ) . toBe ( false ) ;
112113 } ) ;
113114
114115 it ( 'returns true if the props contains an `is` key' , ( ) => {
115- assert . strictEqual (
116- isCustomComponent ( 'button' , { is : 'custom-button' } ) ,
117- true
118- ) ;
116+ expect ( isCustomComponent ( 'button' , { is : 'custom-button' } ) ) . toBe ( true ) ;
119117 } ) ;
120118 } ) ;
121119
@@ -124,7 +122,7 @@ describe('utilities', () => {
124122 parseInt ( React . version . match ( / ^ \d ./ ) [ 0 ] , 10 ) >= 16 ;
125123
126124 it ( `is ${ isReactGreaterThan15 } when React.version="${ React . version } "` , ( ) => {
127- assert . strictEqual ( PRESERVE_CUSTOM_ATTRIBUTES , isReactGreaterThan15 ) ;
125+ expect ( PRESERVE_CUSTOM_ATTRIBUTES ) . toBe ( isReactGreaterThan15 ) ;
128126 } ) ;
129127 } ) ;
130128} ) ;
0 commit comments