Skip to content

Commit 77163a9

Browse files
Lauri PiisangBridgeAR
Lauri Piisang
authored andcommitted
test: add else and error case for TextDecoder
add test for tinyurl.com/codeandlearn-encoding-1 add test for tinyurl.com/codeandlearn-encoding-2 PR-URL: #24162 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent e5e9c64 commit 77163a9

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

+12
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,15 @@ bad.forEach((t) => {
8888
assert(!new TextDecoder().fatal);
8989
assert(new TextDecoder('utf-8', { fatal: true }).fatal);
9090
}
91+
92+
{
93+
const notArrayBufferViewExamples = [false, {}, 1, '', new Error()];
94+
notArrayBufferViewExamples.forEach((invalidInputType) => {
95+
common.expectsError(() => {
96+
new TextDecoder(undefined, null).decode(invalidInputType);
97+
}, {
98+
code: 'ERR_INVALID_ARG_TYPE',
99+
type: TypeError
100+
});
101+
});
102+
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ if (common.hasIntl) {
7575
});
7676
}
7777

78+
// Test TextDecoder, label undefined, options null
79+
{
80+
const dec = new TextDecoder(undefined, null);
81+
assert.strictEqual(dec.encoding, 'utf-8');
82+
assert.strictEqual(dec.fatal, false);
83+
assert.strictEqual(dec.ignoreBOM, false);
84+
}
85+
7886
// Test TextDecoder, UTF-16le
7987
{
8088
const dec = new TextDecoder('utf-16le');

0 commit comments

Comments
 (0)