From 279a24b5d521acfe981b7b9f78b76ca1237257d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Arboleda?= Date: Sun, 30 Oct 2022 00:25:08 -0500 Subject: [PATCH] test: improve test coverage for WHATWG `TextDecoder` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan José Arboleda --- .../test-whatwg-encoding-custom-textdecoder.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/parallel/test-whatwg-encoding-custom-textdecoder.js b/test/parallel/test-whatwg-encoding-custom-textdecoder.js index fe08edc597d3f4..2b53ffff3d1529 100644 --- a/test/parallel/test-whatwg-encoding-custom-textdecoder.js +++ b/test/parallel/test-whatwg-encoding-custom-textdecoder.js @@ -51,6 +51,19 @@ assert(TextDecoder); }); } +// Invalid encoders +{ + ['meow', 'nonunicode', 'foo', 'bar'].forEach((fakeEncoding) => { + assert.throws( + () => { new TextDecoder(fakeEncoding); }, + { + code: 'ERR_ENCODING_NOT_SUPPORTED', + name: 'RangeError' + } + ); + }); +} + // Test TextDecoder, UTF-8, fatal: true, ignoreBOM: false if (common.hasIntl) { ['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {