Add named exports (#432)

This commit is contained in:
Richie Bendall 2021-04-18 00:33:03 +12:00 committed by GitHub
parent fa16f4ec37
commit d798222a5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 147 additions and 165 deletions

View file

@ -1,22 +1,22 @@
import test from 'ava';
import chalk from '../source/index.js';
import chalk, {Chalk} from '../source/index.js';
chalk.level = 1;
test('visible: normal output when level > 0', t => {
const instance = new chalk.Instance({level: 3});
const instance = new Chalk({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 level is too low', t => {
const instance = new chalk.Instance({level: 0});
const instance = new Chalk({level: 0});
t.is(instance.visible.red('foo'), '');
t.is(instance.red.visible('foo'), '');
});
test('test switching back and forth between level == 0 and level > 0', t => {
const instance = new chalk.Instance({level: 3});
const instance = new Chalk({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');