test(stderr): test if stderr work
This commit is contained in:
parent
85f99bb677
commit
6be301b1a4
3 changed files with 35 additions and 0 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const chalk = require('..');
|
const chalk = require('..');
|
||||||
|
const cherr = require('../stderr');
|
||||||
|
|
||||||
console.log(chalk.hex('#ff6159')('test'));
|
console.log(chalk.hex('#ff6159')('test'));
|
||||||
|
console.error(cherr.hex('#ffe861')('test stderr'));
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ const DEFAULT = {
|
||||||
hasBasic: true,
|
hasBasic: true,
|
||||||
has256: true,
|
has256: true,
|
||||||
has16m: true
|
has16m: true
|
||||||
|
},
|
||||||
|
stderr: {
|
||||||
|
level: 3,
|
||||||
|
hasBasic: true,
|
||||||
|
has256: true,
|
||||||
|
has16m: true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
27
test/stderr.js
Normal file
27
test/stderr.js
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import path from 'path';
|
||||||
|
import test from 'ava';
|
||||||
|
import execa from 'execa';
|
||||||
|
|
||||||
|
// Spoof supports-color
|
||||||
|
require('./_supports-color')(__dirname);
|
||||||
|
|
||||||
|
const cherr = require('../stderr');
|
||||||
|
|
||||||
|
test('stderr don\'t output colors when manually disabled', t => {
|
||||||
|
cherr.enabled = false;
|
||||||
|
t.is(cherr.red('foo'), 'foo');
|
||||||
|
cherr.enabled = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('stderr enable/disable colors based on overall chalk enabled property, not individual instances', t => {
|
||||||
|
cherr.enabled = false;
|
||||||
|
const {red} = cherr;
|
||||||
|
t.false(red.enabled);
|
||||||
|
cherr.enabled = true;
|
||||||
|
t.true(red.enabled);
|
||||||
|
cherr.enabled = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('disable colors if they are not supported', async t => {
|
||||||
|
t.is(await execa.stderr('node', [path.join(__dirname, '_fixture')]), 'test stderr');
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue