summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-12-17 11:55:13 -0500
committercjihrig <cjihrig@gmail.com>2018-12-19 12:19:01 -0500
commitbf36f0755c0a41702fe506bcfc90d156030d0497 (patch)
treec203c51148a167aa25d09ca93507f1437663953d /test
parent67f95825e5ad3f80d007613df8b21f4f2819c635 (diff)
downloadandroid-node-v8-bf36f0755c0a41702fe506bcfc90d156030d0497.tar.gz
android-node-v8-bf36f0755c0a41702fe506bcfc90d156030d0497.tar.bz2
android-node-v8-bf36f0755c0a41702fe506bcfc90d156030d0497.zip
console: improve inspectOptions validation
This commit adds stricter type checking to the inspectOptions option to the Console constructor. PR-URL: https://github.com/nodejs/node/pull/25090 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-console-instance.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js
index 127e59e6e5..1c8b54ef4c 100644
--- a/test/parallel/test-console-instance.js
+++ b/test/parallel/test-console-instance.js
@@ -128,3 +128,21 @@ out.write = err.write = (d) => {};
assert.throws(() => c2.warn('foo'), /^Error: err$/);
assert.throws(() => c2.dir('foo'), /^Error: out$/);
}
+
+// Console constructor throws if inspectOptions is not an object.
+[null, true, false, 'foo', 5, Symbol()].forEach((inspectOptions) => {
+ assert.throws(
+ () => {
+ new Console({
+ stdout: out,
+ stderr: err,
+ inspectOptions
+ });
+ },
+ {
+ message: 'The "inspectOptions" argument must be of type object.' +
+ ` Received type ${typeof inspectOptions}`,
+ code: 'ERR_INVALID_ARG_TYPE'
+ }
+ );
+});