Remove the .enabled property in favor of .level (#356)

This commit is contained in:
Qix 2019-07-13 07:45:31 +02:00 committed by Sindre Sorhus
parent 87156ce8e2
commit 1f77953f1a
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(() => {