mirror of
https://github.com/flynx/colors.js.git
synced 2025-10-28 18:40:09 +00:00
improved tests to handle newlines
This commit is contained in:
parent
9aebcadf1b
commit
21448e0e9c
@ -1,5 +1,5 @@
|
||||
var assert = require('assert'),
|
||||
colors = require('../lib/index');
|
||||
colors = require('../lib/index');
|
||||
|
||||
var s = 'string';
|
||||
|
||||
@ -43,8 +43,21 @@ aE(s, 'yellow', 33);
|
||||
|
||||
assert.equal(s, 'string');
|
||||
|
||||
colors.setTheme({error:'red'});
|
||||
var testStringWithNewLines = s + `
|
||||
` + s;
|
||||
|
||||
assert.equal(typeof("astring".red),'string');
|
||||
assert.equal(typeof("astring".error),'string');
|
||||
// single style
|
||||
assert.equal(testStringWithNewLines.red, '\x1b[31m' + s + '\n' + s + '\x1b[39m');
|
||||
|
||||
var testStringWithNewLinesStyled = s.underline + `
|
||||
` + s.bold;
|
||||
|
||||
// nested styles
|
||||
assert.equal(testStringWithNewLinesStyled.red, '\x1b[31m' + '\x1b[4m' + s + '\x1b[24m' + '\n' + '\x1b[1m' + s + '\x1b[22m' + '\x1b[39m');
|
||||
|
||||
colors.setTheme({ error: 'red' });
|
||||
|
||||
assert.equal(typeof ("astring".red), 'string');
|
||||
assert.equal(typeof ("astring".error), 'string');
|
||||
|
||||
assert.equal(s, 'string');
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
var assert = require('assert'),
|
||||
colors = require('../safe');
|
||||
colors = require('../safe');
|
||||
|
||||
var s = 'string';
|
||||
|
||||
@ -39,7 +39,20 @@ aE(s, 'red', 31);
|
||||
aE(s, 'yellow', 33);
|
||||
|
||||
assert.equal(s, 'string');
|
||||
colors.setTheme({error:'red'});
|
||||
|
||||
assert.equal(typeof(colors.red("astring")), 'string');
|
||||
assert.equal(typeof(colors.error("astring")), 'string');
|
||||
var testStringWithNewLines = s + `
|
||||
` + s;
|
||||
|
||||
// single style
|
||||
assert.equal(colors.red(testStringWithNewLines), '\x1b[31m' + s + '\x1b[39m' + '\n' + '\x1b[31m' + s + '\x1b[39m');
|
||||
|
||||
var testStringWithNewLinesStyled = colors.underline(s) + `
|
||||
` + colors.bold(s);
|
||||
|
||||
// nested styles
|
||||
assert.equal(colors.red(testStringWithNewLinesStyled), '\x1b[31m' + '\x1b[4m' + s + '\x1b[24m' + '\x1b[39m' + '\n' + '\x1b[31m' + '\x1b[1m' + s + '\x1b[22m' + '\x1b[39m');
|
||||
|
||||
colors.setTheme({ error: 'red' });
|
||||
|
||||
assert.equal(typeof (colors.red("astring")), 'string');
|
||||
assert.equal(typeof (colors.error("astring")), 'string');
|
||||
Loading…
x
Reference in New Issue
Block a user