@@ -13,10 +13,6 @@ const React = require('react');
13
13
const ReactDOM = require ( 'react-dom' ) ;
14
14
const ReactDOMServer = require ( 'react-dom/server' ) ;
15
15
16
- function normalizeCodeLocInfo ( str ) {
17
- return str && str . replace ( / a t .+ ?: \d + / g, 'at **' ) ;
18
- }
19
-
20
16
describe ( 'CSSPropertyOperations' , ( ) => {
21
17
it ( 'should automatically append `px` to relevant styles' , ( ) => {
22
18
const styles = {
@@ -91,17 +87,13 @@ describe('CSSPropertyOperations', () => {
91
87
}
92
88
}
93
89
94
- spyOnDev ( console , 'error' ) ;
95
90
const root = document . createElement ( 'div' ) ;
96
- ReactDOM . render ( < Comp /> , root ) ;
97
- if ( __DEV__ ) {
98
- expect ( console . error . calls . count ( ) ) . toBe ( 1 ) ;
99
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 0 ) [ 0 ] ) ) . toEqual (
100
- 'Warning: Unsupported style property background-color. Did you mean backgroundColor?' +
101
- '\n in div (at **)' +
102
- '\n in Comp (at **)' ,
103
- ) ;
104
- }
91
+
92
+ expect ( ( ) => ReactDOM . render ( < Comp /> , root ) ) . toWarnDev (
93
+ 'Warning: Unsupported style property background-color. Did you mean backgroundColor?' +
94
+ '\n in div (at **)' +
95
+ '\n in Comp (at **)' ,
96
+ ) ;
105
97
} ) ;
106
98
107
99
it ( 'should warn when updating hyphenated style names' , ( ) => {
@@ -113,28 +105,21 @@ describe('CSSPropertyOperations', () => {
113
105
}
114
106
}
115
107
116
- spyOnDev ( console , 'error' ) ;
117
108
const styles = {
118
109
'-ms-transform' : 'translate3d(0, 0, 0)' ,
119
110
'-webkit-transform' : 'translate3d(0, 0, 0)' ,
120
111
} ;
121
112
const root = document . createElement ( 'div' ) ;
122
113
ReactDOM . render ( < Comp /> , root ) ;
123
- ReactDOM . render ( < Comp style = { styles } /> , root ) ;
124
-
125
- if ( __DEV__ ) {
126
- expect ( console . error . calls . count ( ) ) . toBe ( 2 ) ;
127
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 0 ) [ 0 ] ) ) . toEqual (
128
- 'Warning: Unsupported style property -ms-transform. Did you mean msTransform?' +
129
- '\n in div (at **)' +
130
- '\n in Comp (at **)' ,
131
- ) ;
132
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 1 ) [ 0 ] ) ) . toEqual (
133
- 'Warning: Unsupported style property -webkit-transform. Did you mean WebkitTransform?' +
134
- '\n in div (at **)' +
135
- '\n in Comp (at **)' ,
136
- ) ;
137
- }
114
+
115
+ expect ( ( ) => ReactDOM . render ( < Comp style = { styles } /> , root ) ) . toWarnDev ( [
116
+ 'Warning: Unsupported style property -ms-transform. Did you mean msTransform?' +
117
+ '\n in div (at **)' +
118
+ '\n in Comp (at **)' ,
119
+ 'Warning: Unsupported style property -webkit-transform. Did you mean WebkitTransform?' +
120
+ '\n in div (at **)' +
121
+ '\n in Comp (at **)' ,
122
+ ] ) ;
138
123
} ) ;
139
124
140
125
it ( 'warns when miscapitalizing vendored style names' , ( ) => {
@@ -154,25 +139,19 @@ describe('CSSPropertyOperations', () => {
154
139
}
155
140
}
156
141
157
- spyOnDev ( console , 'error' ) ;
158
142
const root = document . createElement ( 'div' ) ;
159
- ReactDOM . render ( < Comp /> , root ) ;
160
- if ( __DEV__ ) {
143
+
144
+ expect ( ( ) => ReactDOM . render ( < Comp /> , root ) ) . toWarnDev ( [
161
145
// msTransform is correct already and shouldn't warn
162
- expect ( console . error . calls . count ( ) ) . toBe ( 2 ) ;
163
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 0 ) [ 0 ] ) ) . toEqual (
164
- 'Warning: Unsupported vendor-prefixed style property oTransform. ' +
165
- 'Did you mean OTransform?' +
166
- '\n in div (at **)' +
167
- '\n in Comp (at **)' ,
168
- ) ;
169
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 1 ) [ 0 ] ) ) . toEqual (
170
- 'Warning: Unsupported vendor-prefixed style property webkitTransform. ' +
171
- 'Did you mean WebkitTransform?' +
172
- '\n in div (at **)' +
173
- '\n in Comp (at **)' ,
174
- ) ;
175
- }
146
+ 'Warning: Unsupported vendor-prefixed style property oTransform. ' +
147
+ 'Did you mean OTransform?' +
148
+ '\n in div (at **)' +
149
+ '\n in Comp (at **)' ,
150
+ 'Warning: Unsupported vendor-prefixed style property webkitTransform. ' +
151
+ 'Did you mean WebkitTransform?' +
152
+ '\n in div (at **)' +
153
+ '\n in Comp (at **)' ,
154
+ ] ) ;
176
155
} ) ;
177
156
178
157
it ( 'should warn about style having a trailing semicolon' , ( ) => {
@@ -193,24 +172,18 @@ describe('CSSPropertyOperations', () => {
193
172
}
194
173
}
195
174
196
- spyOnDev ( console , 'error' ) ;
197
175
const root = document . createElement ( 'div' ) ;
198
- ReactDOM . render ( < Comp /> , root ) ;
199
- if ( __DEV__ ) {
200
- expect ( console . error . calls . count ( ) ) . toBe ( 2 ) ;
201
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 0 ) [ 0 ] ) ) . toEqual (
202
- "Warning: Style property values shouldn't contain a semicolon. " +
203
- 'Try "backgroundColor: blue" instead.' +
204
- '\n in div (at **)' +
205
- '\n in Comp (at **)' ,
206
- ) ;
207
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 1 ) [ 0 ] ) ) . toEqual (
208
- "Warning: Style property values shouldn't contain a semicolon. " +
209
- 'Try "color: red" instead.' +
210
- '\n in div (at **)' +
211
- '\n in Comp (at **)' ,
212
- ) ;
213
- }
176
+
177
+ expect ( ( ) => ReactDOM . render ( < Comp /> , root ) ) . toWarnDev ( [
178
+ "Warning: Style property values shouldn't contain a semicolon. " +
179
+ 'Try "backgroundColor: blue" instead.' +
180
+ '\n in div (at **)' +
181
+ '\n in Comp (at **)' ,
182
+ "Warning: Style property values shouldn't contain a semicolon. " +
183
+ 'Try "color: red" instead.' +
184
+ '\n in div (at **)' +
185
+ '\n in Comp (at **)' ,
186
+ ] ) ;
214
187
} ) ;
215
188
216
189
it ( 'should warn about style containing a NaN value' , ( ) => {
@@ -222,18 +195,13 @@ describe('CSSPropertyOperations', () => {
222
195
}
223
196
}
224
197
225
- spyOnDev ( console , 'error' ) ;
226
198
const root = document . createElement ( 'div' ) ;
227
- ReactDOM . render ( < Comp /> , root ) ;
228
199
229
- if ( __DEV__ ) {
230
- expect ( console . error . calls . count ( ) ) . toBe ( 1 ) ;
231
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 0 ) [ 0 ] ) ) . toEqual (
232
- 'Warning: `NaN` is an invalid value for the `fontSize` css style property.' +
233
- '\n in div (at **)' +
234
- '\n in Comp (at **)' ,
235
- ) ;
236
- }
200
+ expect ( ( ) => ReactDOM . render ( < Comp /> , root ) ) . toWarnDev (
201
+ 'Warning: `NaN` is an invalid value for the `fontSize` css style property.' +
202
+ '\n in div (at **)' +
203
+ '\n in Comp (at **)' ,
204
+ ) ;
237
205
} ) ;
238
206
239
207
it ( 'should not warn when setting CSS custom properties' , ( ) => {
@@ -256,18 +224,13 @@ describe('CSSPropertyOperations', () => {
256
224
}
257
225
}
258
226
259
- spyOnDev ( console , 'error' ) ;
260
227
const root = document . createElement ( 'div' ) ;
261
- ReactDOM . render ( < Comp /> , root ) ;
262
228
263
- if ( __DEV__ ) {
264
- expect ( console . error . calls . count ( ) ) . toBe ( 1 ) ;
265
- expect ( normalizeCodeLocInfo ( console . error . calls . argsFor ( 0 ) [ 0 ] ) ) . toEqual (
266
- 'Warning: `Infinity` is an invalid value for the `fontSize` css style property.' +
267
- '\n in div (at **)' +
268
- '\n in Comp (at **)' ,
269
- ) ;
270
- }
229
+ expect ( ( ) => ReactDOM . render ( < Comp /> , root ) ) . toWarnDev (
230
+ 'Warning: `Infinity` is an invalid value for the `fontSize` css style property.' +
231
+ '\n in div (at **)' +
232
+ '\n in Comp (at **)' ,
233
+ ) ;
271
234
} ) ;
272
235
273
236
it ( 'should not add units to CSS custom properties' , ( ) => {
0 commit comments