node/test/parallel/test-whatwg-encoding-custom-textdecoder-invalid-arg.js
Joyee Cheung ab02d380e5
test: split test-whatwg-encoding-textdecoder-fatal.js
Split `test-whatwg-encoding-textdecoder-fatal.js` into

- `test-whatwg-encoding-custom-textdecoder-fatal.js` which
  is a customized version of the WPT that tests for Node.js-specific
  error codes.
- `test-whatwg-encoding-custom-textdecoder-invalid-arg` which
  tests `ERR_INVALID_ARG_TYPE`

PR-URL: https://github.com/nodejs/node/pull/25155
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-29 19:20:24 +08:00

19 lines
471 B
JavaScript

'use strict';
// This tests that ERR_INVALID_ARG_TYPE are thrown when
// invalid arguments are passed to TextDecoder.
const common = require('../common');
{
const notArrayBufferViewExamples = [false, {}, 1, '', new Error()];
notArrayBufferViewExamples.forEach((invalidInputType) => {
common.expectsError(() => {
new TextDecoder(undefined, null).decode(invalidInputType);
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
});
}