@@ -176,6 +176,133 @@ describe('parseMeasurement', () => {
176
176
it . todo ( 'test' ) ;
177
177
} ) ;
178
178
describe ( 'parseUrl' , ( ) => {
179
+ it ( 'should return undefined' , ( ) => {
180
+ let input = 'url(var(--foo))' ;
181
+ let output = parsers . parseUrl ( input ) ;
182
+
183
+ assert . strictEqual ( output , undefined ) ;
184
+ } ) ;
185
+
186
+ it ( 'should return quoted url string' , ( ) => {
187
+ let input = 'url(sample.png)' ;
188
+ let output = parsers . parseUrl ( input ) ;
189
+
190
+ assert . strictEqual ( output , 'url("sample.png")' ) ;
191
+ } ) ;
192
+
193
+ it ( 'should return quoted url string' , ( ) => {
194
+ let input = "url('sample.png')" ;
195
+ let output = parsers . parseUrl ( input ) ;
196
+
197
+ assert . strictEqual ( output , 'url("sample.png")' ) ;
198
+ } ) ;
199
+
200
+ it ( 'should return quoted url string' , ( ) => {
201
+ let input = 'url("sample.png")' ;
202
+ let output = parsers . parseUrl ( input ) ;
203
+
204
+ assert . strictEqual ( output , 'url("sample.png")' ) ;
205
+ } ) ;
206
+
207
+ it ( 'should return quoted url string without escape' , ( ) => {
208
+ let input = 'url(sample\\-escaped.png)' ;
209
+ let output = parsers . parseUrl ( input ) ;
210
+
211
+ assert . strictEqual ( output , 'url("sample-escaped.png")' ) ;
212
+ } ) ;
213
+
214
+ it ( 'should return quoted url string with escape' , ( ) => {
215
+ let input = 'url(sample\\\\-escaped.png)' ;
216
+ let output = parsers . parseUrl ( input ) ;
217
+
218
+ assert . strictEqual ( output , 'url("sample\\\\-escaped.png")' ) ;
219
+ } ) ;
220
+
221
+ it ( 'should return undefined' , ( ) => {
222
+ let input = 'url(sample unescaped -space.png)' ;
223
+ let output = parsers . parseUrl ( input ) ;
224
+
225
+ assert . strictEqual ( output , undefined ) ;
226
+ } ) ;
227
+
228
+ it ( 'should return quoted url string without escape' , ( ) => {
229
+ let input = 'url(sample\\ escaped\\ -space.png)' ;
230
+ let output = parsers . parseUrl ( input ) ;
231
+
232
+ assert . strictEqual ( output , 'url("sample escaped -space.png")' ) ;
233
+ } ) ;
234
+
235
+ it ( 'should return undefined' , ( ) => {
236
+ let input = 'url(sample\tunescaped\t-tab.png)' ;
237
+ let output = parsers . parseUrl ( input ) ;
238
+
239
+ assert . strictEqual ( output , undefined ) ;
240
+ } ) ;
241
+
242
+ it ( 'should return quoted url string without escape' , ( ) => {
243
+ let input = 'url(sample\\\tescaped\\\t-tab.png)' ;
244
+ let output = parsers . parseUrl ( input ) ;
245
+
246
+ assert . strictEqual ( output , 'url("sample\tescaped\t-tab.png")' ) ;
247
+ } ) ;
248
+
249
+ it ( 'should return undefined' , ( ) => {
250
+ let input = 'url(sample\nunescaped\n-lf.png)' ;
251
+ let output = parsers . parseUrl ( input ) ;
252
+
253
+ assert . strictEqual ( output , undefined ) ;
254
+ } ) ;
255
+
256
+ it ( 'should return quoted url string without escape' , ( ) => {
257
+ let input = 'url(sample\\\nescaped\\\n-lf.png)' ;
258
+ let output = parsers . parseUrl ( input ) ;
259
+
260
+ assert . strictEqual ( output , 'url("sample\nescaped\n-lf.png")' ) ;
261
+ } ) ;
262
+
263
+ it ( 'should return undefined' , ( ) => {
264
+ let input = "url(sample'unescaped'-quote.png)" ;
265
+ let output = parsers . parseUrl ( input ) ;
266
+
267
+ assert . strictEqual ( output , undefined ) ;
268
+ } ) ;
269
+
270
+ it ( 'should return quoted url string without escape' , ( ) => {
271
+ let input = "url(sample\\'escaped\\'-quote.png)" ;
272
+ let output = parsers . parseUrl ( input ) ;
273
+
274
+ // prettier-ignore
275
+ assert . strictEqual ( output , "url(\"sample'escaped'-quote.png\")" ) ;
276
+ } ) ;
277
+
278
+ it ( 'should return undefined' , ( ) => {
279
+ let input = 'url(sample"unescaped"-double-quote.png)' ;
280
+ let output = parsers . parseUrl ( input ) ;
281
+
282
+ assert . strictEqual ( output , undefined ) ;
283
+ } ) ;
284
+
285
+ it ( 'should return quoted url string with escape' , ( ) => {
286
+ let input = 'url(sample\\"escaped\\"-double-quote.png)' ;
287
+ let output = parsers . parseUrl ( input ) ;
288
+
289
+ assert . strictEqual ( output , 'url("sample\\"escaped\\"-double-quote.png")' ) ;
290
+ } ) ;
291
+
292
+ it ( 'should return quoted empty url string' , ( ) => {
293
+ let input = 'url()' ;
294
+ let output = parsers . parseUrl ( input ) ;
295
+
296
+ assert . strictEqual ( output , 'url("")' ) ;
297
+ } ) ;
298
+
299
+ it ( 'should return quoted empty url string' , ( ) => {
300
+ let input = 'url("")' ;
301
+ let output = parsers . parseUrl ( input ) ;
302
+
303
+ assert . strictEqual ( output , 'url("")' ) ;
304
+ } ) ;
305
+
179
306
it . todo ( 'test' ) ;
180
307
} ) ;
181
308
describe ( 'parseString' , ( ) => {
@@ -314,28 +441,28 @@ describe('parseImage', () => {
314
441
let input = 'url(example.png)' ;
315
442
let output = parsers . parseImage ( input ) ;
316
443
317
- assert . strictEqual ( output , 'url(example.png)' ) ;
444
+ assert . strictEqual ( output , 'url(" example.png" )' ) ;
318
445
} ) ;
319
446
320
447
it ( 'should return value' , ( ) => {
321
448
let input = 'url(example.png), url("example2.png")' ;
322
449
let output = parsers . parseImage ( input ) ;
323
450
324
- assert . strictEqual ( output , 'url(example.png), url(example2.png)' ) ;
451
+ assert . strictEqual ( output , 'url(" example.png" ), url(" example2.png" )' ) ;
325
452
} ) ;
326
453
327
454
it ( 'should return value' , ( ) => {
328
455
let input = 'none, url(example.png)' ;
329
456
let output = parsers . parseImage ( input ) ;
330
457
331
- assert . strictEqual ( output , 'none, url(example.png)' ) ;
458
+ assert . strictEqual ( output , 'none, url(" example.png" )' ) ;
332
459
} ) ;
333
460
334
461
it ( 'should return value' , ( ) => {
335
462
let input = 'linear-gradient(green, blue), url(example.png)' ;
336
463
let output = parsers . parseImage ( input ) ;
337
464
338
- assert . strictEqual ( output , 'linear-gradient(green, blue), url(example.png)' ) ;
465
+ assert . strictEqual ( output , 'linear-gradient(green, blue), url(" example.png" )' ) ;
339
466
} ) ;
340
467
341
468
it ( 'should return value as is if var() is included' , ( ) => {
0 commit comments