@@ -232,35 +232,46 @@ test('prepareValue: can safely be used to map an array of values including those
232
232
} )
233
233
234
234
const testEscapeLiteral = function ( testName , input , expected ) {
235
- test ( testName , function ( ) {
235
+ test ( `escapeLiteral: ${ testName } ` , function ( ) {
236
236
const actual = utils . escapeLiteral ( input )
237
237
assert . equal ( expected , actual )
238
238
} )
239
239
}
240
- testEscapeLiteral ( 'escapeLiteral: no special characters' , 'hello world' , "'hello world'" )
241
240
242
- testEscapeLiteral ( 'escapeLiteral: contains double quotes only ' , 'hello " world' , "'hello \" world'" )
241
+ testEscapeLiteral ( 'no special characters ' , 'hello world' , "'hello world'" )
243
242
244
- testEscapeLiteral ( 'escapeLiteral: contains single quotes only' , " hello ' world" , "'hello '' world'" )
243
+ testEscapeLiteral ( 'contains double quotes only' , ' hello " world' , "'hello \" world'" )
245
244
246
- testEscapeLiteral ( 'escapeLiteral: contains backslashes only' , ' hello \\ world' , " E 'hello \\\\ world'" )
245
+ testEscapeLiteral ( 'contains single quotes only' , " hello ' world" , "'hello '' world'" )
247
246
248
- testEscapeLiteral ( 'escapeLiteral: contains single quotes and double quotes ' , 'hello \' " world' , "'hello '' \" world'" )
247
+ testEscapeLiteral ( 'contains backslashes only ' , 'hello \\ world' , " E 'hello \\\\ world'" )
249
248
250
- testEscapeLiteral (
251
- 'escapeLiteral: contains double quotes and backslashes' ,
252
- 'hello \\ " world' ,
253
- " E'hello \\\\ \" world'"
254
- )
249
+ testEscapeLiteral ( 'contains single quotes and double quotes' , 'hello \' " world' , "'hello '' \" world'" )
255
250
256
- testEscapeLiteral (
257
- 'escapeLiteral: contains single quotes and backslashes' ,
258
- "hello \\ ' world" ,
259
- " E'hello \\\\ '' world'"
260
- )
251
+ testEscapeLiteral ( 'date' , new Date ( ) , "''" )
252
+
253
+ testEscapeLiteral ( 'null' , null , "''" )
254
+
255
+ testEscapeLiteral ( 'undefined' , undefined , "''" )
256
+
257
+ testEscapeLiteral ( 'boolean' , false , "''" )
258
+
259
+ testEscapeLiteral ( 'number' , 1 , "''" )
260
+
261
+ testEscapeLiteral ( 'number' , 1 , "''" )
262
+
263
+ testEscapeLiteral ( 'boolean' , true , "''" )
264
+
265
+ testEscapeLiteral ( 'array' , [ 1 , 2 , 3 ] , "''" )
266
+
267
+ testEscapeLiteral ( 'object' , { x : 42 } , "''" )
268
+
269
+ testEscapeLiteral ( 'contains double quotes and backslashes' , 'hello \\ " world' , " E'hello \\\\ \" world'" )
270
+
271
+ testEscapeLiteral ( 'contains single quotes and backslashes' , "hello \\ ' world" , " E'hello \\\\ '' world'" )
261
272
262
273
testEscapeLiteral (
263
- 'escapeLiteral: contains single quotes, double quotes, and backslashes' ,
274
+ 'contains single quotes, double quotes, and backslashes' ,
264
275
'hello \\ \' " world' ,
265
276
" E'hello \\\\ '' \" world'"
266
277
)
0 commit comments