From 42e9d8016af2d3473b34b0536a9b44a6016f5346 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Sun, 30 Oct 2022 19:52:37 +0000 Subject: [PATCH] test: fix textdecoder test for small-icu builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Kohei Ueno Reviewed-By: Tobias Nießen Reviewed-By: Steven R Loomis --- .../test-whatwg-encoding-custom-textdecoder.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-whatwg-encoding-custom-textdecoder.js b/test/parallel/test-whatwg-encoding-custom-textdecoder.js index fe08edc597d3f4..74c6a002223255 100644 --- a/test/parallel/test-whatwg-encoding-custom-textdecoder.js +++ b/test/parallel/test-whatwg-encoding-custom-textdecoder.js @@ -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'); + } }