From 271a861e0523ab0d8f7e46a1792a029a20b174f6 Mon Sep 17 00:00:00 2001 From: Masashi Hirano Date: Mon, 11 Jun 2018 06:47:12 +0900 Subject: [PATCH] test: add test to check colorMode type of Console PR-URL: https://github.com/nodejs/node/pull/21248 Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: Lance Ball --- test/parallel/test-console-tty-colors.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/parallel/test-console-tty-colors.js b/test/parallel/test-console-tty-colors.js index 945c21f28a27de..4f4064970ad6b7 100644 --- a/test/parallel/test-console-tty-colors.js +++ b/test/parallel/test-console-tty-colors.js @@ -44,3 +44,27 @@ check(true, true, true); check(false, true, true); check(true, false, false); check(false, false, false); + +// check invalid colorMode type +{ + const stream = new Writable({ + write: common.mustNotCall() + }); + + [0, 'true', null, {}, [], () => {}].forEach((colorMode) => { + const received = util.inspect(colorMode); + assert.throws( + () => { + new Console({ + stdout: stream, + ignoreErrors: false, + colorMode: colorMode + }); + }, + { + message: `The argument 'colorMode' is invalid. Received ${received}`, + code: 'ERR_INVALID_ARG_VALUE' + } + ); + }); +}