From fe9888a34a4367e90fe17d695d5ae1f555ce64da Mon Sep 17 00:00:00 2001 From: Masashi Hirano Date: Mon, 2 Jul 2018 03:52:30 +0900 Subject: [PATCH] test: check type for Worker filename argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Trivikram Kamat Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum Reviewed-By: Minwoo Jung Reviewed-By: Tiancheng "Timothy" Gu --- test/parallel/test-worker-type-check.js | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/parallel/test-worker-type-check.js diff --git a/test/parallel/test-worker-type-check.js b/test/parallel/test-worker-type-check.js new file mode 100644 index 00000000000000..43013bc538712a --- /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}` + } + ); + }); +}