summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan José Arboleda <soyjuanarbol@gmail.com>2020-04-20 18:34:23 -0500
committerMichaël Zasso <targos@protonmail.com>2020-05-04 14:23:23 +0200
commit92c7e0620f83f0db76a5b8264d6e4b380176f869 (patch)
treeed17afee45b688abcf5e118265724db1896465c5
parent82e459d9afe3db68198f8c6b8cfc1b819692dd01 (diff)
downloadnode-new-92c7e0620f83f0db76a5b8264d6e4b380176f869.tar.gz
test: check args on SourceTextModule cachedData
PR-URL: https://github.com/nodejs/node/pull/32956 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host>
-rw-r--r--test/parallel/test-vm-module-errors.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/parallel/test-vm-module-errors.js b/test/parallel/test-vm-module-errors.js
index 5f36f9339f..d14296b1e9 100644
--- a/test/parallel/test-vm-module-errors.js
+++ b/test/parallel/test-vm-module-errors.js
@@ -209,6 +209,22 @@ async function checkInvalidOptionForEvaluate() {
});
}
+function checkInvalidCachedData() {
+ [true, false, 'foo', {}, Array, function() {}].forEach((invalidArg) => {
+ const message = 'The "options.cachedData" property must be an ' +
+ 'instance of Buffer, TypedArray, or DataView.' +
+ common.invalidArgTypeHelper(invalidArg);
+ assert.throws(
+ () => new SourceTextModule('import "foo";', { cachedData: invalidArg }),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ name: 'TypeError',
+ message,
+ }
+ );
+ });
+}
+
const finished = common.mustCall();
(async function main() {
@@ -217,5 +233,6 @@ const finished = common.mustCall();
await checkLinking();
await checkExecution();
await checkInvalidOptionForEvaluate();
+ checkInvalidCachedData();
finished();
})();