* 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)
This commit is contained in:
l198881 2021-05-26 15:23:19 -03:00 committed by GitHub
parent 9776a2ae5b
commit 029b69e482
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 760 additions and 479 deletions

View file

@ -5,38 +5,38 @@ import execa from 'execa';
// Spoof supports-color
require('./_supports-color')(__dirname);
const m = require('..');
const chalk = require('..');
test('don\'t output colors when manually disabled', t => {
const oldLevel = m.level;
m.level = 0;
t.is(m.red('foo'), 'foo');
m.level = oldLevel;
const oldLevel = chalk.level;
chalk.level = 0;
t.is(chalk.red('foo'), 'foo');
chalk.level = oldLevel;
});
test('enable/disable colors based on overall chalk enabled property, not individual instances', t => {
const oldLevel = m.level;
m.level = 1;
const red = m.red;
const oldLevel = chalk.level;
chalk.level = 1;
const {red} = chalk;
t.is(red.level, 1);
m.level = 0;
t.is(red.level, m.level);
m.level = oldLevel;
chalk.level = 0;
t.is(red.level, chalk.level);
chalk.level = oldLevel;
});
test('propagate enable/disable changes from child colors', t => {
const oldLevel = m.level;
m.level = 1;
const red = m.red;
const oldLevel = chalk.level;
chalk.level = 1;
const {red} = chalk;
t.is(red.level, 1);
t.is(m.level, 1);
t.is(chalk.level, 1);
red.level = 0;
t.is(red.level, 0);
t.is(m.level, 0);
m.level = 1;
t.is(chalk.level, 0);
chalk.level = 1;
t.is(red.level, 1);
t.is(m.level, 1);
m.level = oldLevel;
t.is(chalk.level, 1);
chalk.level = oldLevel;
});
test('disable colors if they are not supported', async t => {