Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add failing template tests
  • Loading branch information
Qix- committed Aug 7, 2017
1 parent 7dbd8c3 commit 7a75399
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/template-literal.js
Expand Up @@ -93,3 +93,26 @@ test('escape interpolated values', t => {
t.is(ctx`Hello {bold hi}`, 'Hello hi');
t.is(ctx`Hello ${'{bold hi}'}`, 'Hello {bold hi}');
});

test('allow custom colors (themes) on custom contexts', t => {
const ctx = m.constructor({level: 3});
ctx.rose = ctx.hex('#F6D9D9');
t.is(ctx`Hello, {rose Rose}.`, '\u001b[0mHello, \u001b[38;2;246;217;217mRose\u001b[38m.\u001b[0m');
});

test('correctly parse newline literals (bug #184)', t => {
const ctx = m.constructor({level: 0});
t.is(ctx`Hello
{red there}`, 'Hello\nthere');
});

test('correctly parse newline escapes (bug #177)', t => {
const ctx = m.constructor({level: 0});
t.is(ctx`Hello\nthere!`, `Hello\nthere!`);
});

test('correctly parse escape in parameters (bug #177 comment 318622809)', t => {
const ctx = m.constructor({level: 0});
const str = '\\';
t.is(ctx`{blue ${str}}`, '\\');
});

0 comments on commit 7a75399

Please sign in to comment.