test: fix textdecoder test for small-icu builds
The `Shift_JIS` encoding may not be available, e.g. when Node.js is configured with `--with-intl=small-icu`. PR-URL: https://github.com/nodejs/node/pull/45225 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
This commit is contained in:
parent
77c0448ede
commit
e43ecd5fec
@ -201,8 +201,13 @@ if (common.hasIntl) {
|
||||
}
|
||||
|
||||
if (common.hasIntl) {
|
||||
const decoder = new TextDecoder('Shift_JIS');
|
||||
const chunk = new Uint8Array([-1]);
|
||||
const str = decoder.decode(chunk);
|
||||
assert.strictEqual(str, '\ufffd');
|
||||
try {
|
||||
const decoder = new TextDecoder('Shift_JIS');
|
||||
const chunk = new Uint8Array([-1]);
|
||||
const str = decoder.decode(chunk);
|
||||
assert.strictEqual(str, '\ufffd');
|
||||
} catch (e) {
|
||||
// Encoding may not be available, e.g. small-icu builds
|
||||
assert.strictEqual(e.code, 'ERR_ENCODING_NOT_SUPPORTED');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user