* Fix XO linting and update some dev dependencies Fixes #275 * Add some badges to the readme * Tiny travis.yml tweak * Require Node.js 6 * Validate the `level` option Fixes #248 * Add failing test for #234 (#235) * Add type definitions badge (#286) * Add Tidelift mention in the readme * Replace RawGit URL Fixes #305 * Fix ignore chars regex flags in rainbow example (#306) Use global matches rather than stopping after the first match. * Strict mode in Flow definition (#309) * Add security section * Add docs comments and tests for TypeScript definitions (#299) Fixes #293 * Update dependencies and meta tweaks * Type definition improvements * Enforce `chalk.constructor` to be called with `new` in TypeScript * Add extra level/enabled property info in the readme (#308) * Code style tweaks * Change tagged template literal argument type to accept `unknown` instead of just `string` (#316)
35 lines
835 B
JavaScript
35 lines
835 B
JavaScript
import test from 'ava';
|
|
|
|
// Spoof supports-color
|
|
require('./_supports-color')(__dirname);
|
|
|
|
const chalk = require('..');
|
|
|
|
test('don\'t output colors when manually disabled', t => {
|
|
chalk.enabled = false;
|
|
t.is(chalk.red('foo'), 'foo');
|
|
chalk.enabled = true;
|
|
});
|
|
|
|
test('enable/disable colors based on overall chalk enabled property, not individual instances', t => {
|
|
chalk.enabled = false;
|
|
const {red} = chalk;
|
|
t.false(red.enabled);
|
|
chalk.enabled = true;
|
|
t.true(red.enabled);
|
|
chalk.enabled = true;
|
|
});
|
|
|
|
test('propagate enable/disable changes from child colors', t => {
|
|
chalk.enabled = false;
|
|
const {red} = chalk;
|
|
t.false(red.enabled);
|
|
t.false(chalk.enabled);
|
|
red.enabled = true;
|
|
t.true(red.enabled);
|
|
t.true(chalk.enabled);
|
|
chalk.enabled = false;
|
|
t.false(red.enabled);
|
|
t.false(chalk.enabled);
|
|
chalk.enabled = true;
|
|
});
|