@@ -30,6 +30,25 @@ test('correctly perform template substitutions', t => {
3030instance . bold ( 'Hello,' , instance . cyan . inverse ( name + '!' ) , 'This is a' ) + ' test. ' + instance . green ( exclamation + '!' ) ) ;
3131} ) ;
3232
33+ test ( 'correctly perform nested template substitutions' , t => {
34+ const instance = new chalk . Instance ( { level : 0 } ) ;
35+ const name = 'Sindre' ;
36+ const exclamation = 'Neat' ;
37+ t . is ( instance . bold `Hello, {cyan.inverse ${ name } !} This is a` + ' test. ' + instance . green `${ exclamation } !` ,
38+ instance . bold ( 'Hello,' , instance . cyan . inverse ( name + '!' ) , 'This is a' ) + ' test. ' + instance . green ( exclamation + '!' ) ) ;
39+
40+ t . is ( instance . red . bgGreen . bold `Hello {italic.blue ${ name } }` ,
41+ instance . red . bgGreen . bold ( 'Hello ' + instance . italic . blue ( name ) ) ) ;
42+
43+ t . is ( instance . strikethrough . cyanBright . bgBlack `Works with {reset {bold numbers}} {bold.red ${ 1 } }` ,
44+ instance . strikethrough . cyanBright . bgBlack ( 'Works with ' + instance . reset . bold ( 'numbers' ) + ' ' + instance . bold . red ( 1 ) ) ) ;
45+
46+ t . is ( chalk . bold `Also works on the shared {bgBlue chalk} object` ,
47+ '\u001B[1mAlso works on the shared \u001B[1m' +
48+ '\u001B[44mchalk\u001B[49m\u001B[22m' +
49+ '\u001B[1m object\u001B[22m' ) ;
50+ } ) ;
51+
3352test ( 'correctly parse and evaluate color-convert functions' , t => {
3453const instance = new chalk . Instance ( { level : 3 } ) ;
3554t . is ( instance `{bold.rgb(144,10,178).inverse Hello, {~inverse there!}}` ,
0 commit comments