Fix support for bracketed Unicode escapes in template literals (#350)

This commit is contained in:
Qix 2019-07-12 08:35:11 +02:00 committed by Sindre Sorhus
parent e2dd171597
commit 983094883c
2 changed files with 17 additions and 3 deletions

View file

@ -168,3 +168,10 @@ test('should properly handle undefined template interpolated values', t => {
t.is(instance`hello ${undefined}`, 'hello undefined');
t.is(instance`hello ${null}`, 'hello null');
});
test('should allow bracketed Unicode escapes', t => {
const instance = new chalk.Instance({level: 3});
t.is(instance`\u{AB}`, '\u{AB}');
t.is(instance`This is a {bold \u{AB681}} test`, 'This is a \u001B[1m\u{AB681}\u001B[22m test');
t.is(instance`This is a {bold \u{10FFFF}} test`, 'This is a \u001B[1m\u{10FFFF}\u001B[22m test');
});