@@ -286,7 +286,7 @@ describe('builtin helpers', function() {
286
286
} ;
287
287
288
288
shouldCompileTo ( string , [ hash , , , , { level : '03' } ] , '' ) ;
289
- equals ( 3 , levelArg ) ;
289
+ equals ( '03' , levelArg ) ;
290
290
equals ( 'whee' , logArg ) ;
291
291
} ) ;
292
292
it ( 'should output to info' , function ( ) {
@@ -327,6 +327,66 @@ describe('builtin helpers', function() {
327
327
328
328
shouldCompileTo ( string , [ hash , , , , { level : '03' } ] , '' ) ;
329
329
} ) ;
330
+
331
+ it ( 'should handle string log levels' , function ( ) {
332
+ var string = '{{log blah}}' ;
333
+ var hash = { blah : 'whee' } ;
334
+ var called ;
335
+
336
+ console . error = function ( log ) {
337
+ equals ( 'whee' , log ) ;
338
+ called = true ;
339
+ } ;
340
+
341
+ shouldCompileTo ( string , [ hash , , , , { level : 'error' } ] , '' ) ;
342
+ equals ( true , called ) ;
343
+
344
+ called = false ;
345
+
346
+ shouldCompileTo ( string , [ hash , , , , { level : 'ERROR' } ] , '' ) ;
347
+ equals ( true , called ) ;
348
+ } ) ;
349
+ it ( 'should handle hash log levels' , function ( ) {
350
+ var string = '{{log blah level="error"}}' ;
351
+ var hash = { blah : 'whee' } ;
352
+ var called ;
353
+
354
+ console . error = function ( log ) {
355
+ equals ( 'whee' , log ) ;
356
+ called = true ;
357
+ } ;
358
+
359
+ shouldCompileTo ( string , hash , '' ) ;
360
+ equals ( true , called ) ;
361
+ } ) ;
362
+ it ( 'should handle hash log levels' , function ( ) {
363
+ var string = '{{log blah level="debug"}}' ;
364
+ var hash = { blah : 'whee' } ;
365
+ var called = false ;
366
+
367
+ console . info = console . log = console . error = console . debug = function ( log ) {
368
+ equals ( 'whee' , log ) ;
369
+ called = true ;
370
+ } ;
371
+
372
+ shouldCompileTo ( string , hash , '' ) ;
373
+ equals ( false , called ) ;
374
+ } ) ;
375
+ it ( 'should pass multiple log arguments' , function ( ) {
376
+ var string = '{{log blah "foo" 1}}' ;
377
+ var hash = { blah : 'whee' } ;
378
+ var called ;
379
+
380
+ console . info = console . log = function ( log1 , log2 , log3 ) {
381
+ equals ( 'whee' , log1 ) ;
382
+ equals ( 'foo' , log2 ) ;
383
+ equals ( 1 , log3 ) ;
384
+ called = true ;
385
+ } ;
386
+
387
+ shouldCompileTo ( string , hash , '' ) ;
388
+ equals ( true , called ) ;
389
+ } ) ;
330
390
/*eslint-enable no-console */
331
391
} ) ;
332
392
0 commit comments