From 9da7a2dbd2ccdcd8c30e9fcb0577796a82fdcedf 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..d25d7b1f9bed91 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: new RegExp(`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) => {