summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMasashi Hirano <cherrydog07@gmail.com>2018-07-02 03:52:30 +0900
committerTrivikram Kamat <16024985+trivikr@users.noreply.github.com>2018-07-04 00:51:21 -0700
commit0b2ad91ad309c4cc047ac2098452b953342beefa (patch)
tree7c8786f3141d7accbc697259edb24809dcc2d55f /test
parentf374d6aaf9a2a171c9cd100a4ca2d26a68f72cb8 (diff)
downloadandroid-node-v8-0b2ad91ad309c4cc047ac2098452b953342beefa.tar.gz
android-node-v8-0b2ad91ad309c4cc047ac2098452b953342beefa.tar.bz2
android-node-v8-0b2ad91ad309c4cc047ac2098452b953342beefa.zip
test: check type for Worker filename argument
Add test to check type for first argument of Worker to increase coverage. PR-URL: https://github.com/nodejs/node/pull/21620 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-worker-type-check.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/parallel/test-worker-type-check.js b/test/parallel/test-worker-type-check.js
new file mode 100644
index 0000000000..43013bc538
--- /dev/null
+++ b/test/parallel/test-worker-type-check.js
@@ -0,0 +1,28 @@
+// Flags: --experimental-worker
+'use strict';
+
+const common = require('../common');
+const { Worker } = require('worker_threads');
+
+{
+ [
+ undefined,
+ null,
+ false,
+ 0,
+ Symbol('test'),
+ {},
+ [],
+ () => {}
+ ].forEach((val) => {
+ common.expectsError(
+ () => new Worker(val),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError,
+ message: 'The "filename" argument must be of type string. ' +
+ `Received type ${typeof val}`
+ }
+ );
+ });
+}