Skip to content

Commit 42e9d80

Browse files
committed
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: #45225 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Kohei Ueno <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Steven R Loomis <[email protected]>
1 parent 38202d3 commit 42e9d80

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/parallel/test-whatwg-encoding-custom-textdecoder.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,13 @@ if (common.hasIntl) {
201201
}
202202

203203
if (common.hasIntl) {
204-
const decoder = new TextDecoder('Shift_JIS');
205-
const chunk = new Uint8Array([-1]);
206-
const str = decoder.decode(chunk);
207-
assert.strictEqual(str, '\ufffd');
204+
try {
205+
const decoder = new TextDecoder('Shift_JIS');
206+
const chunk = new Uint8Array([-1]);
207+
const str = decoder.decode(chunk);
208+
assert.strictEqual(str, '\ufffd');
209+
} catch (e) {
210+
// Encoding may not be available, e.g. small-icu builds
211+
assert.strictEqual(e.code, 'ERR_ENCODING_NOT_SUPPORTED');
212+
}
208213
}

0 commit comments

Comments
 (0)