◐ Shell
clean mode source ↗

test: add test to check colorMode type of Console · nodejs/node@d7ba75f

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+

}