Skip to content

Commit d7ba75f

Browse files
Masashi Hiranotargos
Masashi Hirano
authored andcommitted
test: add test to check colorMode type of Console
PR-URL: #21248 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Lance Ball <[email protected]>
1 parent 0b90b07 commit d7ba75f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/parallel/test-console-tty-colors.js

+24
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,27 @@ check(true, true, true);
4444
check(false, true, true);
4545
check(true, false, false);
4646
check(false, false, false);
47+
48+
// check invalid colorMode type
49+
{
50+
const stream = new Writable({
51+
write: common.mustNotCall()
52+
});
53+
54+
[0, 'true', null, {}, [], () => {}].forEach((colorMode) => {
55+
const received = util.inspect(colorMode);
56+
assert.throws(
57+
() => {
58+
new Console({
59+
stdout: stream,
60+
ignoreErrors: false,
61+
colorMode: colorMode
62+
});
63+
},
64+
{
65+
message: `The argument 'colorMode' is invalid. Received ${received}`,
66+
code: 'ERR_INVALID_ARG_VALUE'
67+
}
68+
);
69+
});
70+
}

0 commit comments

Comments
 (0)