summaryrefslogtreecommitdiff
path: root/test/parallel/test-whatwg-encoding-custom-textdecoder-invalid-arg.js
blob: 5c8a9837f68f3bc7c6b86169a961d482543475e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';

// This tests that ERR_INVALID_ARG_TYPE are thrown when
// invalid arguments are passed to TextDecoder.

require('../common');
const assert = require('assert');

{
  const notArrayBufferViewExamples = [false, {}, 1, '', new Error()];
  notArrayBufferViewExamples.forEach((invalidInputType) => {
    assert.throws(() => {
      new TextDecoder(undefined, null).decode(invalidInputType);
    }, {
      code: 'ERR_INVALID_ARG_TYPE',
      name: 'TypeError'
    });
  });
}