@@ -13,15 +13,19 @@ describe('normalizeClass', () => {
13
13
14
14
test ( 'handles string correctly' , ( ) => {
15
15
expect ( normalizeClass ( 'foo' ) ) . toEqual ( 'foo' )
16
- expect ( normalizeClass ( 'foo1 ' ) ) . toEqual ( 'foo1' )
17
16
} )
18
17
19
18
test ( 'handles array correctly' , ( ) => {
20
- expect ( normalizeClass ( [ 'foo ' , undefined , true , false , 'bar' ] ) ) . toEqual (
19
+ expect ( normalizeClass ( [ 'foo' , undefined , true , false , 'bar' ] ) ) . toEqual (
21
20
'foo bar' ,
22
21
)
23
22
} )
24
23
24
+ test ( 'handles string containing spaces correctly' , ( ) => {
25
+ expect ( normalizeClass ( 'foo1 ' ) ) . toEqual ( 'foo1' )
26
+ expect ( normalizeClass ( [ 'foo ' , ' baz ' ] ) ) . toEqual ( 'foo baz' )
27
+ } )
28
+
25
29
test ( 'handles empty array correctly' , ( ) => {
26
30
expect ( normalizeClass ( [ ] ) ) . toEqual ( '' )
27
31
} )
@@ -104,6 +108,7 @@ describe('normalizeStyle', () => {
104
108
test ( 'handles string correctly' , ( ) => {
105
109
expect ( normalizeStyle ( 'foo' ) ) . toEqual ( 'foo' )
106
110
} )
111
+
107
112
test ( 'handles array correctly' , ( ) => {
108
113
const style : any = normalizeStyle ( [
109
114
`border: 1px solid transparent;
@@ -116,7 +121,9 @@ describe('normalizeStyle', () => {
116
121
white 0.75em
117
122
);` ,
118
123
] )
124
+
119
125
expect ( style . border ) . toEqual ( '1px solid transparent' )
126
+
120
127
expect ( style . background ) . toEqual ( `linear-gradient(white, white) padding-box,
121
128
repeating-linear-gradient(
122
129
-45deg,
@@ -126,6 +133,7 @@ describe('normalizeStyle', () => {
126
133
white 0.75em
127
134
)` )
128
135
} )
136
+
129
137
test ( 'handles object correctly' , ( ) => {
130
138
const styleObj = {
131
139
border : '1px solid transparent' ,
@@ -145,27 +153,28 @@ describe('normalizeStyle', () => {
145
153
} )
146
154
147
155
describe ( 'stringifyStyle' , ( ) => {
148
- it ( 'should return empty string for undefined or string styles' , ( ) => {
156
+ test ( 'should return empty string for undefined or string styles' , ( ) => {
149
157
expect ( stringifyStyle ( undefined ) ) . toBe ( '' )
150
158
expect ( stringifyStyle ( '' ) ) . toBe ( '' )
151
159
expect ( stringifyStyle ( 'color: blue;' ) ) . toBe ( '' )
152
160
} )
153
161
154
- it ( 'should return valid CSS string for normalized style object' , ( ) => {
162
+ test ( 'should return valid CSS string for normalized style object' , ( ) => {
155
163
const style = {
156
164
color : 'blue' ,
157
165
fontSize : '14px' ,
158
166
backgroundColor : 'white' ,
159
167
opacity : 0.8 ,
168
+ margin : 0 ,
160
169
'--custom-color' : 'red' ,
161
170
}
162
171
163
172
expect ( stringifyStyle ( style ) ) . toBe (
164
- 'color:blue;font-size:14px;background-color:white;opacity:0.8;--custom-color:red;' ,
173
+ 'color:blue;font-size:14px;background-color:white;opacity:0.8;margin:0; --custom-color:red;' ,
165
174
)
166
175
} )
167
176
168
- it ( 'should ignore non-string or non-number values in style object' , ( ) => {
177
+ test ( 'should ignore non-string or non-number values in style object' , ( ) => {
169
178
const style : any = {
170
179
color : 'blue' ,
171
180
fontSize : '14px' ,
0 commit comments