@@ -11,120 +11,134 @@ var attributesToProps = require('../lib/attributes-to-props');
11
11
*/
12
12
describe ( 'attributes to props helper' , function ( ) {
13
13
14
- it ( 'converts DOM attributes to React props' , function ( ) {
15
- assert . deepEqual (
16
- attributesToProps ( {
17
- 'class' : 'ic' ,
18
- 'for' : 'tran' ,
19
- 'http-equiv' : 'refresh'
20
- } ) ,
21
- {
22
- className : 'ic' ,
23
- htmlFor : 'tran' ,
24
- httpEquiv : 'refresh' ,
25
- }
26
- ) ;
27
- } ) ;
14
+ /**
15
+ * HTML DOM property to React prop.
16
+ */
17
+ describe ( 'HTML DOM' , function ( ) {
28
18
29
- it ( 'converts DOM standard properties to React props' , function ( ) {
30
- assert . deepEqual (
31
- attributesToProps ( {
32
- allowfullscreen : true ,
33
- charset : 'utf-8 ' ,
34
- tabindex : 1
35
- } ) ,
36
- {
37
- allowFullScreen : true ,
38
- charSet : 'utf-8 ' ,
39
- tabIndex : 1
40
- }
41
- ) ;
42
- } ) ;
19
+ it ( 'converts attributes to React props' , function ( ) {
20
+ assert . deepEqual (
21
+ attributesToProps ( {
22
+ 'class' : 'ic' ,
23
+ 'for' : 'tran ' ,
24
+ 'http-equiv' : 'refresh'
25
+ } ) ,
26
+ {
27
+ className : 'ic' ,
28
+ htmlFor : 'tran ' ,
29
+ httpEquiv : 'refresh' ,
30
+ }
31
+ ) ;
32
+ } ) ;
43
33
44
- it ( 'converts DOM RDFa properties to React props' , function ( ) {
45
- assert . deepEqual (
46
- attributesToProps ( {
47
- property : 'foo' ,
48
- 'typeof' : 'bar'
49
- } ) ,
50
- {
51
- property : 'foo' ,
52
- 'typeof' : 'bar'
53
- }
54
- ) ;
55
- } ) ;
34
+ it ( 'converts standard properties to React props' , function ( ) {
35
+ assert . deepEqual (
36
+ attributesToProps ( {
37
+ allowfullscreen : true ,
38
+ charset : 'utf-8' ,
39
+ tabindex : 1
40
+ } ) ,
41
+ {
42
+ allowFullScreen : true ,
43
+ charSet : 'utf-8' ,
44
+ tabIndex : 1
45
+ }
46
+ ) ;
47
+ } ) ;
56
48
57
- it ( 'converts DOM non-standard properties to React props' , function ( ) {
58
- assert . deepEqual (
59
- attributesToProps ( {
60
- itemscope : true ,
61
- itemid : 1337
62
- } ) ,
63
- {
64
- itemScope : true ,
65
- itemID : 1337
66
- }
67
- ) ;
68
- } ) ;
49
+ it ( 'converts RDFa properties to React props' , function ( ) {
50
+ assert . deepEqual (
51
+ attributesToProps ( {
52
+ property : 'foo' ,
53
+ 'typeof' : 'bar'
54
+ } ) ,
55
+ {
56
+ property : 'foo' ,
57
+ 'typeof' : 'bar'
58
+ }
59
+ ) ;
60
+ } ) ;
69
61
70
- it ( 'keeps data- and aria- attributes as is' , function ( ) {
71
- assert . deepEqual (
72
- attributesToProps ( {
73
- 'data-foo' : 'bar' ,
74
- 'aria-live' : 'polite'
75
- } ) ,
76
- {
77
- 'data-foo' : 'bar' ,
78
- 'aria-live' : 'polite'
79
- }
80
- ) ;
81
- } ) ;
62
+ it ( 'converts non-standard properties to React props' , function ( ) {
63
+ assert . deepEqual (
64
+ attributesToProps ( {
65
+ itemscope : true ,
66
+ itemid : 1337
67
+ } ) ,
68
+ {
69
+ itemScope : true ,
70
+ itemID : 1337
71
+ }
72
+ ) ;
73
+ } ) ;
74
+
75
+ it ( 'keeps `data-` and `aria-` attributes as is' , function ( ) {
76
+ assert . deepEqual (
77
+ attributesToProps ( {
78
+ 'data-foo' : 'bar' ,
79
+ 'aria-live' : 'polite'
80
+ } ) ,
81
+ {
82
+ 'data-foo' : 'bar' ,
83
+ 'aria-live' : 'polite'
84
+ }
85
+ ) ;
86
+ } ) ;
87
+
88
+ it ( 'converts properties with weird capitalization' , function ( ) {
89
+ assert . deepEqual (
90
+ attributesToProps ( {
91
+ 'ACCEPT-CHARSET' : 'ISO-8859-1' ,
92
+ formNOvalidate : true ,
93
+ sEcUrItY : 'restricted' ,
94
+ 'data-FOO' : 'bar'
95
+ } ) ,
96
+ {
97
+ acceptCharset : 'ISO-8859-1' ,
98
+ formNoValidate : true ,
99
+ security : 'restricted' ,
100
+ 'data-FOO' : 'bar'
101
+ }
102
+ ) ;
103
+ } ) ;
82
104
83
- it ( 'converts DOM attributes with weird capitalization' , function ( ) {
84
- assert . deepEqual (
85
- attributesToProps ( {
86
- 'ACCEPT-CHARSET' : 'ISO-8859-1' ,
87
- formNOvalidate : true ,
88
- sEcUrItY : 'restricted' ,
89
- 'data-FOO' : 'bar'
90
- } ) ,
91
- {
92
- acceptCharset : 'ISO-8859-1' ,
93
- formNoValidate : true ,
94
- security : 'restricted' ,
95
- 'data-FOO' : 'bar'
96
- }
97
- ) ;
98
105
} ) ;
99
106
100
- it ( 'converts CSS style string to JS style object' , function ( ) {
101
- // proper css
102
- assert . deepEqual (
103
- attributesToProps ( {
104
- style : 'color: #f00; font-size: 42px; z-index: -1;'
105
- } ) ,
106
- {
107
- style : {
108
- color : '#f00' ,
109
- fontSize : '42px' ,
110
- zIndex : '-1'
107
+ /**
108
+ * Style string to object.
109
+ */
110
+ describe ( 'style' , function ( ) {
111
+
112
+ it ( 'converts CSS style string to JS style object' , function ( ) {
113
+ // proper css
114
+ assert . deepEqual (
115
+ attributesToProps ( {
116
+ style : 'color: #f00; font-size: 42px; z-index: -1;'
117
+ } ) ,
118
+ {
119
+ style : {
120
+ color : '#f00' ,
121
+ fontSize : '42px' ,
122
+ zIndex : '-1'
123
+ }
111
124
}
112
- }
113
- ) ;
125
+ ) ;
114
126
115
- // valid but messy
116
- assert . deepEqual (
117
- attributesToProps ( {
118
- style : 'border-bottom-left-radius:1em;border-right-style:solid;Z-Index:-1'
119
- } ) ,
120
- {
121
- style : {
122
- borderBottomLeftRadius : '1em' ,
123
- borderRightStyle : 'solid' ,
124
- zIndex : '-1'
127
+ // valid but messy
128
+ assert . deepEqual (
129
+ attributesToProps ( {
130
+ style : 'border-bottom-left-radius:1em;border-right-style:solid;Z-Index:-1'
131
+ } ) ,
132
+ {
133
+ style : {
134
+ borderBottomLeftRadius : '1em' ,
135
+ borderRightStyle : 'solid' ,
136
+ zIndex : '-1'
137
+ }
125
138
}
126
- }
127
- ) ;
139
+ ) ;
140
+ } ) ;
141
+
128
142
} ) ;
129
143
130
144
} ) ;
0 commit comments