File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -430,6 +430,11 @@ describe('cliui', function () {
430
430
} )
431
431
432
432
it ( 'ignores ansi escape codes when measuring padding' , function ( ) {
433
+ // Forcefully enable color-codes for this test
434
+ const { enabled, level } = chalk
435
+ chalk . enabled = true
436
+ chalk . level = 1
437
+
433
438
var ui = cliui ( {
434
439
width : 25
435
440
} )
@@ -448,6 +453,32 @@ describe('cliui', function () {
448
453
' '
449
454
]
450
455
456
+ ui . toString ( ) . split ( '\n' ) . map ( function ( l ) {
457
+ return stripAnsi ( l )
458
+ } ) . should . eql ( expected )
459
+ chalk . enabled = enabled
460
+ chalk . level = level
461
+ } )
462
+
463
+ it ( 'correctly handles lack of ansi escape codes when measuring padding' , function ( ) {
464
+ var ui = cliui ( {
465
+ width : 25
466
+ } )
467
+
468
+ // using figlet font 'Shadow' rendering of text 'true' here
469
+ ui . div (
470
+ ' | \n __| __| | | _ \\ \n | | | | __/ \n \\__| _| \\__,_| \\___| \n '
471
+ )
472
+
473
+ // The difference
474
+ var expected = [
475
+ ' |' ,
476
+ ' __| __| | | _ \\' ,
477
+ ' | | | | __/' ,
478
+ ' \\__| _| \\__,_| \\___|' ,
479
+ ''
480
+ ]
481
+
451
482
ui . toString ( ) . split ( '\n' ) . map ( function ( l ) {
452
483
return stripAnsi ( l )
453
484
} ) . should . eql ( expected )
You can’t perform that action at this time.
0 commit comments