diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-11-26 00:32:16 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-07 00:31:07 +0100 |
commit | 832290a0d425aa027c279a4a96a70550a2fdfff2 (patch) | |
tree | 1979058b478e79f454e3bec754cd73e263636cfb /test | |
parent | 2a0ec9c6459f50301a989a6df1b89358c3a9158c (diff) | |
download | android-node-v8-832290a0d425aa027c279a4a96a70550a2fdfff2.tar.gz android-node-v8-832290a0d425aa027c279a4a96a70550a2fdfff2.tar.bz2 android-node-v8-832290a0d425aa027c279a4a96a70550a2fdfff2.zip |
util: add more predefined color codes to inspect.colors
This adds most commonly used ANSI color codes to
`util.inspect.colors`.
PR-URL: https://github.com/nodejs/node/pull/30659
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-util-inspect.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 0d905b1e72..3f4a3a8a15 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -2076,6 +2076,34 @@ assert.strictEqual(inspect(new BigUint64Array([0n])), 'BigUint64Array [ 0n ]'); `\u001b[${string[0]}m'Oh no!'\u001b[${string[1]}m }` ); rejection.catch(() => {}); + + // Verify that aliases do not show up as key while checking `inspect.colors`. + const colors = Object.keys(inspect.colors); + const aliases = Object.getOwnPropertyNames(inspect.colors) + .filter((c) => !colors.includes(c)); + assert(!colors.includes('grey')); + assert(colors.includes('gray')); + // Verify that all aliases are correctly mapped. + for (const alias of aliases) { + assert(Array.isArray(inspect.colors[alias])); + } + // Check consistent naming. + [ + 'black', + 'red', + 'green', + 'yellow', + 'blue', + 'magenta', + 'cyan', + 'white' + ].forEach((color, i) => { + assert.deepStrictEqual(inspect.colors[color], [30 + i, 39]); + assert.deepStrictEqual(inspect.colors[`${color}Bright`], [90 + i, 39]); + const bgColor = `bg${color[0].toUpperCase()}${color.slice(1)}`; + assert.deepStrictEqual(inspect.colors[bgColor], [40 + i, 49]); + assert.deepStrictEqual(inspect.colors[`${bgColor}Bright`], [100 + i, 49]); + }); } assert.strictEqual( |