forked from orbit-oss/chalk
Demonstrate crash when using Truecolor methods and color is unsupported (#174)
This commit is contained in:
parent
23092eefd2
commit
5cdd9eddf8
3 changed files with 13 additions and 0 deletions
4
fixture.js
Normal file
4
fixture.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
'use strict';
|
||||
const chalk = require('.');
|
||||
|
||||
console.log(chalk.hex('#ff6159')('test'));
|
||||
|
|
@ -46,6 +46,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"coveralls": "^2.11.2",
|
||||
"execa": "^0.7.0",
|
||||
"import-fresh": "^2.0.0",
|
||||
"matcha": "^0.7.0",
|
||||
"mocha": "*",
|
||||
|
|
|
|||
8
test.js
8
test.js
|
|
@ -2,6 +2,7 @@
|
|||
const assert = require('assert');
|
||||
const importFresh = require('import-fresh');
|
||||
const resolveFrom = require('resolve-from');
|
||||
const execa = require('execa');
|
||||
|
||||
// Spoof supports-color
|
||||
require.cache[resolveFrom(__dirname, 'supports-color')] = {
|
||||
|
|
@ -202,6 +203,13 @@ describe('chalk.level', () => {
|
|||
assert.equal(chalk.level, 1);
|
||||
chalk.level = oldLevel;
|
||||
});
|
||||
|
||||
it('should disable colors if they are not supported', () => {
|
||||
return execa('node', ['fixture'])
|
||||
.then(result => {
|
||||
assert.equal(result.stdout, 'test');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('chalk.enabled', () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue