Skip to content
Permalink
Browse files

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: #25155
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
joyeecheung authored and targos committed Dec 20, 2018
1 parent a8f5191 commit deceb2623898d2303c9ffa9143861b16b00f11af
@@ -1,6 +1,7 @@
'use strict';

// From: https://github.com/w3c/web-platform-tests/blob/39a67e2fff/encoding/textdecoder-fatal.html
// With the twist that we specifically test for Node.js error codes

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

@@ -82,21 +83,10 @@ bad.forEach((t) => {
);
});

// TODO(joyeecheung): remove this when WPT is ported
{
assert('fatal' in new TextDecoder());
assert.strictEqual(typeof new TextDecoder().fatal, 'boolean');
assert(!new TextDecoder().fatal);
assert(new TextDecoder('utf-8', { fatal: true }).fatal);
}

{
const notArrayBufferViewExamples = [false, {}, 1, '', new Error()];
notArrayBufferViewExamples.forEach((invalidInputType) => {
common.expectsError(() => {
new TextDecoder(undefined, null).decode(invalidInputType);
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
});
}
@@ -0,0 +1,18 @@
'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
});
});
}

0 comments on commit deceb26

Please sign in to comment.
You can’t perform that action at this time.