summaryrefslogtreecommitdiff
path: root/test/wasi/test-wasi-options-validation.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/wasi/test-wasi-options-validation.js')
-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' });