From f6fe293c4767fc751dc426242cb18b5dfa794ae1 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/parallel/test-whatwg-encoding-custom-textdecoder.js b/test/parallel/test-whatwg-encoding-custom-textdecoder.js index fe08edc597d3f4..a41bc4c02e3031 100644 --- a/test/parallel/test-whatwg-encoding-custom-textdecoder.js +++ b/test/parallel/test-whatwg-encoding-custom-textdecoder.js @@ -51,6 +51,20 @@ assert(TextDecoder); }); } +// Invalid encoders +{ + ['meow', 'nonunicode', 'foo', 'bar'].forEach((fakeEncoding) => { + assert.throws( + () => { new TextDecoder(fakeEncoding); }, + { + code: 'ERR_ENCODING_NOT_SUPPORTED', + name: 'RangeError', + message: `The "${fakeEncoding}" encoding is not supported` + } + ); + }); +} + // Test TextDecoder, UTF-8, fatal: true, ignoreBOM: false if (common.hasIntl) { ['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {