node/test/parallel/test-whatwg-encoding-custom-textdecoder-api-invalid-label.js
Rich Trott 330f25ef82 test: prepare for consistent comma-dangle lint rule
Make changes so that tests will pass when the comma-dangle settings
applied to the rest of the code base are also applied to tests.

PR-URL: https://github.com/nodejs/node/pull/37930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
2021-04-01 23:14:29 -07:00

42 lines
893 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
require('../common');
const assert = require('assert');
[
'utf-8',
'unicode-1-1-utf-8',
'utf8',
'utf-16be',
'utf-16le',
'utf-16',
].forEach((i) => {
['\u0000', '\u000b', '\u00a0', '\u2028', '\u2029'].forEach((ws) => {
assert.throws(
() => new TextDecoder(`${ws}${i}`),
{
code: 'ERR_ENCODING_NOT_SUPPORTED',
name: 'RangeError'
}
);
assert.throws(
() => new TextDecoder(`${i}${ws}`),
{
code: 'ERR_ENCODING_NOT_SUPPORTED',
name: 'RangeError'
}
);
assert.throws(
() => new TextDecoder(`${ws}${i}${ws}`),
{
code: 'ERR_ENCODING_NOT_SUPPORTED',
name: 'RangeError'
}
);
});
});