0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
nodejs/test/wasi/test-wasi-options-validation.js
Rich Trott 147317f60c test: improve WASI options validation
Refs: https://github.com/nodejs/node/pull/30770/files#r353051438

PR-URL: https://github.com/nodejs/node/pull/30800
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-12-07 09:02:59 -08:00

23 lines
827 B
JavaScript

'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', message: /\bargs\b/ });
// If env is not an Object and not undefined, it should throw.
assert.throws(() => { new WASI({ env: 'fhqwhgads' }); },
{ code: 'ERR_INVALID_ARG_TYPE', message: /\benv\b/ });
// If preopens is not an Object and not undefined, it should throw.
assert.throws(() => { new WASI({ preopens: 'fhqwhgads' }); },
{ code: 'ERR_INVALID_ARG_TYPE', message: /\bpreopens\b/ });