Remove the .enabled property in favor of .level (#356)
This commit is contained in:
parent
87156ce8e2
commit
1f77953f1a
9 changed files with 17 additions and 101 deletions
|
|
@ -5,40 +5,34 @@ require('./_supports-color')(__dirname);
|
|||
|
||||
const chalk = require('../source');
|
||||
|
||||
test('visible: normal output when enabled', t => {
|
||||
const instance = new chalk.Instance({level: 3, enabled: true});
|
||||
test('visible: normal output when level > 0', t => {
|
||||
const instance = new chalk.Instance({level: 3});
|
||||
t.is(instance.visible.red('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
t.is(instance.red.visible('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
});
|
||||
|
||||
test('visible: no output when disabled', t => {
|
||||
const instance = new chalk.Instance({level: 3, enabled: false});
|
||||
t.is(instance.red.visible('foo'), '');
|
||||
t.is(instance.visible.red('foo'), '');
|
||||
});
|
||||
|
||||
test('visible: no output when level is too low', t => {
|
||||
const instance = new chalk.Instance({level: 0, enabled: true});
|
||||
const instance = new chalk.Instance({level: 0});
|
||||
t.is(instance.visible.red('foo'), '');
|
||||
t.is(instance.red.visible('foo'), '');
|
||||
});
|
||||
|
||||
test('test switching back and forth between enabled and disabled', t => {
|
||||
const instance = new chalk.Instance({level: 3, enabled: true});
|
||||
test('test switching back and forth between level == 0 and level > 0', t => {
|
||||
const instance = new chalk.Instance({level: 3});
|
||||
t.is(instance.red('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
t.is(instance.visible.red('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
t.is(instance.red.visible('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
t.is(instance.visible('foo'), 'foo');
|
||||
t.is(instance.red('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
|
||||
instance.enabled = false;
|
||||
instance.level = 0;
|
||||
t.is(instance.red('foo'), 'foo');
|
||||
t.is(instance.visible('foo'), '');
|
||||
t.is(instance.visible.red('foo'), '');
|
||||
t.is(instance.red.visible('foo'), '');
|
||||
t.is(instance.red('foo'), 'foo');
|
||||
|
||||
instance.enabled = true;
|
||||
instance.level = 3;
|
||||
t.is(instance.red('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
t.is(instance.visible.red('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
t.is(instance.red.visible('foo'), '\u001B[31mfoo\u001B[39m');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue