Skip to content

Commit e21d784

Browse files
Lauri Piisangcodebytere
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 <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 33fd13c commit e21d784

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
@@ -91,3 +91,15 @@ bad.forEach((t) => {
9191
assert(!new TextDecoder().fatal);
9292
assert(new TextDecoder('utf-8', { fatal: true }).fatal);
9393
}
94+
95+
{
96+
const notArrayBufferViewExamples = [false, {}, 1, '', new Error()];
97+
notArrayBufferViewExamples.forEach((invalidInputType) => {
98+
common.expectsError(() => {
99+
new TextDecoder(undefined, null).decode(invalidInputType);
100+
}, {
101+
code: 'ERR_INVALID_ARG_TYPE',
102+
type: TypeError
103+
});
104+
});
105+
}

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

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

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

0 commit comments

Comments
 (0)