mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 12:03:30 +00:00

Split test-whatwg-encoding-textdecoder.js into: - `test-whatwg-encoding-custom-textdecoder.js` which tests Node.js-specific behaviors - `test-whatwg-encoding-custom-textdecoder-api-invalid-label.js` which is a customized version of the WPT counterpart - `test-whatwg-encoding-custom-api-basics.js` which is the part of `test-whatwg-encoding-api-basics.js` that can be run without ICU - `test-whatwg-encoding-api-basics.js` which can be replaced with WPT later. PR-URL: https://github.com/nodejs/node/pull/25155 Reviewed-By: James M Snell <jasnell@gmail.com>
41 lines
885 B
JavaScript
41 lines
885 B
JavaScript
'use strict';
|
|
// From: https://github.com/w3c/web-platform-tests/blob/master/encoding/api-invalid-label.html
|
|
// With the twist that we specifically test for Node.js error codes
|
|
|
|
const common = require('../common');
|
|
|
|
[
|
|
'utf-8',
|
|
'unicode-1-1-utf-8',
|
|
'utf8',
|
|
'utf-16be',
|
|
'utf-16le',
|
|
'utf-16'
|
|
].forEach((i) => {
|
|
['\u0000', '\u000b', '\u00a0', '\u2028', '\u2029'].forEach((ws) => {
|
|
common.expectsError(
|
|
() => new TextDecoder(`${ws}${i}`),
|
|
{
|
|
code: 'ERR_ENCODING_NOT_SUPPORTED',
|
|
type: RangeError
|
|
}
|
|
);
|
|
|
|
common.expectsError(
|
|
() => new TextDecoder(`${i}${ws}`),
|
|
{
|
|
code: 'ERR_ENCODING_NOT_SUPPORTED',
|
|
type: RangeError
|
|
}
|
|
);
|
|
|
|
common.expectsError(
|
|
() => new TextDecoder(`${ws}${i}${ws}`),
|
|
{
|
|
code: 'ERR_ENCODING_NOT_SUPPORTED',
|
|
type: RangeError
|
|
}
|
|
);
|
|
});
|
|
});
|