Add failing test for #234 (#235)

This commit is contained in:
Chris Harwood 2018-09-18 04:48:47 -04:00 committed by Sindre Sorhus
parent 2a678789b1
commit 6a14c58e54
2 changed files with 27 additions and 11 deletions

View file

@ -1,15 +1,15 @@
'use strict';
const resolveFrom = require('resolve-from');
module.exports = dir => {
require.cache[resolveFrom(dir, 'supports-color')] = {
exports: {
stdout: {
level: 3,
hasBasic: true,
has256: true,
has16m: true
}
}
};
const DEFAULT = {
stdout: {
level: 3,
hasBasic: true,
has256: true,
has16m: true
}
};
module.exports = (dir, override) => {
require.cache[resolveFrom(dir, 'supports-color')] = {exports: override || DEFAULT};
};

16
test/no-color-support.js Normal file
View file

@ -0,0 +1,16 @@
import test from 'ava';
// Spoof supports-color
require('./_supports-color')(__dirname, {
level: 0,
hasBasic: false,
has256: false,
has16m: false
});
const chalk = require('..');
test.failing('colors can be forced by using chalk.enabled', t => {
chalk.enabled = true;
t.is(chalk.green('hello'), '\u001B[32mhello\u001B[39m');
});