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>
This commit is contained in:
parent
74a9221f6f
commit
ab02d380e5
@ -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
|
||||
});
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user