add .hasColor() method - fixes #23

This commit is contained in:
Sindre Sorhus 2014-06-24 21:34:11 +02:00
parent eff96c2c15
commit 90bd6477d6
4 changed files with 15 additions and 1 deletions

View file

@ -63,6 +63,13 @@ describe('chalk.styles', function () {
});
});
describe('chalk.hasColor()', function () {
it('should detect whether a string has color', function () {
assert(chalk.hasColor(chalk.blue('foo')));
assert(!chalk.hasColor(chalk.stripColor(chalk.blue('foo'))));
});
});
describe('chalk.stripColor()', function () {
it('should strip color from string', function () {
assert.equal(chalk.stripColor(chalk.underline.red.bgGreen('foo')), 'foo');