2017-07-23 22:17:33 +02:00
|
|
|
import test from 'ava';
|
|
|
|
|
|
|
|
|
|
// Spoof supports-color
|
|
|
|
|
require('./_supports-color')(__dirname);
|
|
|
|
|
|
2018-09-18 14:05:08 +07:00
|
|
|
const chalk = require('..');
|
2017-07-23 22:17:33 +02:00
|
|
|
|
|
|
|
|
test('create an isolated context where colors can be disabled (by level)', t => {
|
2018-09-18 14:05:08 +07:00
|
|
|
const instance = new chalk.constructor({level: 0, enabled: true});
|
|
|
|
|
t.is(instance.red('foo'), 'foo');
|
|
|
|
|
t.is(chalk.red('foo'), '\u001B[31mfoo\u001B[39m');
|
|
|
|
|
instance.level = 2;
|
|
|
|
|
t.is(instance.red('foo'), '\u001B[31mfoo\u001B[39m');
|
2017-07-23 22:17:33 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('create an isolated context where colors can be disabled (by enabled flag)', t => {
|
2018-09-18 14:05:08 +07:00
|
|
|
const instance = new chalk.constructor({enabled: false});
|
|
|
|
|
t.is(instance.red('foo'), 'foo');
|
|
|
|
|
t.is(chalk.red('foo'), '\u001B[31mfoo\u001B[39m');
|
|
|
|
|
instance.enabled = true;
|
|
|
|
|
t.is(instance.red('foo'), '\u001B[31mfoo\u001B[39m');
|
2017-07-23 22:17:33 +02:00
|
|
|
});
|