summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-12-02 12:25:39 -0800
committerRich Trott <rtrott@gmail.com>2019-12-04 20:11:14 -0800
commitbcd5491219bfd34630d331bdca3c92538a7b0e5e (patch)
tree1c334272137141ea2b9332cf8279aac8966dd62e
parentcc5c3b557ee8f52dcbfa42984f38a80c55e6c3be (diff)
downloadandroid-node-v8-bcd5491219bfd34630d331bdca3c92538a7b0e5e.tar.gz
android-node-v8-bcd5491219bfd34630d331bdca3c92538a7b0e5e.tar.bz2
android-node-v8-bcd5491219bfd34630d331bdca3c92538a7b0e5e.zip
test: improve wasi test coverage
Add test coverage for options validation in WASI constructor. PR-URL: https://github.com/nodejs/node/pull/30770 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net>
-rw-r--r--test/wasi/test-wasi-options-validation.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/wasi/test-wasi-options-validation.js b/test/wasi/test-wasi-options-validation.js
new file mode 100644
index 0000000000..34ab7e078f
--- /dev/null
+++ b/test/wasi/test-wasi-options-validation.js
@@ -0,0 +1,22 @@
+'use strict';
+
+// Flags: --experimental-wasi-unstable-preview0
+
+require('../common');
+const assert = require('assert');
+const { WASI } = require('wasi');
+
+// If args is undefined, it should default to [] and should not throw.
+new WASI({});
+
+// If args is not an Array and not undefined, it should throw.
+assert.throws(() => { new WASI({ args: 'fhqwhgads' }); },
+ { code: 'ERR_INVALID_ARG_TYPE' });
+
+// If env is not an Object and not undefined, it should throw.
+assert.throws(() => { new WASI({ env: 'fhqwhgads' }); },
+ { code: 'ERR_INVALID_ARG_TYPE' });
+
+// If preopens is not an Object and not undefined, it should throw.
+assert.throws(() => { new WASI({ preopens: 'fhqwhgads' }); },
+ { code: 'ERR_INVALID_ARG_TYPE' });