Close #54 PR: export classy chalk object to create isolated ctx. Fixes #46, Fixes #46

This commit is contained in:
David Keijser 2015-02-17 15:18:18 +07:00 committed by Sindre Sorhus
parent 4d9c98c603
commit 72d1c11e43
3 changed files with 31 additions and 15 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({enabled: 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');