Add failing test for #234

* Change .gitignore to support IntellJ IDEs
* Change .gitignore to specify that node_modules and coverage are folders
* Modify supports-color mock to allow export override
* Add failing test showing that enabled does not work
This commit is contained in:
Chris Harwood 2017-12-15 17:11:31 -05:00
parent 84f27d4bd8
commit 9756f160ba
No known key found for this signature in database
GPG key ID: 5AFFD5BBAA5A3B05
3 changed files with 30 additions and 13 deletions

5
.gitignore vendored
View file

@ -1,4 +1,5 @@
node_modules
.idea/
node_modules/
coverage/
yarn.lock
coverage
.nyc_output

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 m = require('..');
test.failing('can be forced on using chalk.enabled', t => {
m.enabled = true;
t.is(m.green('hello'), '\u001B[32mhello\u001B[39m');
});