export classy chalk object to create isolated ctx

This commit is contained in:
David Keijser 2015-01-23 15:45:40 +01:00
parent aa7e67741f
commit eeadb9f40d
2 changed files with 25 additions and 13 deletions

View file

@ -68,6 +68,14 @@ describe('chalk.enabled', function () {
});
});
describe('chalk.constructor', function () {
it('should create a isolated context where colors can be disabled', function () {
var ctx = new chalk.constructor(false);
assert.equal(ctx.red('foo'), 'foo');
assert.equal(chalk.red('foo'), '\u001b[31mfoo\u001b[39m');
});
});
describe('chalk.styles', function () {
it('should expose the styles as ANSI escape codes', function () {
assert.equal(chalk.styles.red.open, '\u001b[31m');