11/* eslint-disable no-undef */
22const assert = require ( 'assert' ) ,
3- tmessentials = require ( '../' ) ;
3+ tmessentials = require ( '../src/index ' ) ;
44
55describe ( "Text Formatting" , function ( ) {
66 it ( "should deformat text" , function ( ) {
77 assert . equal ( "Hello World!" , tmessentials . TextFormatter . deformat ( "$f08Hello$z$s $5f8$w$oWorld$z$w!" ) ) ;
88 assert . equal ( "small bold text" , tmessentials . TextFormatter . deformat ( "$0f0$nsmall$z$s $5f0$wbold$z $539text" ) ) ;
99 } ) ;
10+
11+ it ( "should format text with ANSI escape codes" , function ( ) {
12+ assert . equal (
13+ "\u001b[38;2;255;255;0mHello \u001b[38;2;0;255;255mWorld\u001b[38;2;255;255;255m! \u001b[38;2;0;0;0mI'm \u001b[38;2;255;255;255ma \u001b[38;2;0;0;255mBlue \u001b[38;2;255;0;0mRed \u001b[38;2;0;255;0mGreen \u001b[39m\u001b[22mText \u001b[38;2;255;255;0m$wWide\u001b[39m\u001b[22m" ,
14+ tmessentials . TextFormatter . formatAnsi ( "$ff0Hello $0ffWorld$fff! $000I'm $fffa $00fBlue $f00Red $0f0Green $zText $ff0$wWide" )
15+ ) ;
16+
17+ assert . equal (
18+ "$w$o\u001b[38;2;255;0;0mT\u001b[38;2;221;0;17mM\u001b[38;2;204;17;51mU\u001b[38;2;170;17;68m.\u001b[38;2;136;17;85mK\u001b[38;2;119;34;119mr\u001b[38;2;85;34;136ma\u001b[38;2;51;34;153mz\u001b[38;2;34;51;187my\u001b[38;2;0;51;204mC\u001b[38;2;0;51;204mo\u001b[38;2;0;68;187ml\u001b[38;2;0;85;153mo\u001b[38;2;0;102;136mr\u001b[38;2;0;119;119ms\u001b[38;2;0;136;85m \u001b[38;2;0;153;68mv\u001b[38;2;0;170;51m0\u001b[38;2;0;187;17m.\u001b[38;2;0;204;0m1\u001b[39m\u001b[22m" ,
19+ tmessentials . TextFormatter . formatAnsi ( "$w$o$F00T$D01M$C13U$A14.$815K$727r$528a$329z$23By$03CC$03Co$04Bl$059o$068r$077s$085 $094v$0A30$0B1.$0C01" )
20+ ) ;
21+ } ) ;
22+
23+ it ( "should format text with ANSI escape codes + deformat" , function ( ) {
24+ assert . equal (
25+ "\u001b[38;2;255;255;0mHello \u001b[38;2;0;255;255mWorld\u001b[38;2;255;255;255m! \u001b[38;2;0;0;0mI'm \u001b[38;2;255;255;255ma \u001b[38;2;0;0;255mBlue \u001b[38;2;255;0;0mRed \u001b[38;2;0;255;0mGreen \u001b[39m\u001b[22mText \u001b[38;2;255;255;0mWide\u001b[39m\u001b[22m" ,
26+ tmessentials . TextFormatter . deformat (
27+ tmessentials . TextFormatter . formatAnsi ( "$ff0Hello $0ffWorld$fff! $000I'm $fffa $00fBlue $f00Red $0f0Green $zText $ff0$wWide" )
28+ )
29+ ) ;
30+
31+ assert . equal (
32+ "\u001b[38;2;255;0;0mT\u001b[38;2;221;0;17mM\u001b[38;2;204;17;51mU\u001b[38;2;170;17;68m.\u001b[38;2;136;17;85mK\u001b[38;2;119;34;119mr\u001b[38;2;85;34;136ma\u001b[38;2;51;34;153mz\u001b[38;2;34;51;187my\u001b[38;2;0;51;204mC\u001b[38;2;0;51;204mo\u001b[38;2;0;68;187ml\u001b[38;2;0;85;153mo\u001b[38;2;0;102;136mr\u001b[38;2;0;119;119ms\u001b[38;2;0;136;85m \u001b[38;2;0;153;68mv\u001b[38;2;0;170;51m0\u001b[38;2;0;187;17m.\u001b[38;2;0;204;0m1\u001b[39m\u001b[22m" ,
33+ tmessentials . TextFormatter . deformat (
34+ tmessentials . TextFormatter . formatAnsi ( "$w$o$F00T$D01M$C13U$A14.$815K$727r$528a$329z$23By$03CC$03Co$04Bl$059o$068r$077s$085 $094v$0A30$0B1.$0C01" )
35+ )
36+ ) ;
37+ } ) ;
1038} ) ;
0 commit comments