remove the .enabled property in lieu of .level (closes #234)

This commit is contained in:
Josh Junon 2019-07-12 20:05:36 +02:00
parent c25c32a25f
commit 024068f9f5
9 changed files with 17 additions and 101 deletions

View file

@ -6,21 +6,13 @@ require('./_supports-color')(__dirname);
const chalk = require('../source');
test('create an isolated context where colors can be disabled (by level)', t => {
const instance = new chalk.Instance({level: 0, enabled: true});
const instance = new chalk.Instance({level: 0});
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');
});
test('create an isolated context where colors can be disabled (by enabled flag)', t => {
const instance = new chalk.Instance({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');
});
test('the `level` option should be a number from 0 to 3', t => {
/* eslint-disable no-new */
t.throws(() => {