Skip to content

Commit

Permalink
test: add else and error case for TextDecoder
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Lauri Piisang authored and codebytere committed Jan 12, 2019
1 parent 33fd13c commit e21d784
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/parallel/test-whatwg-encoding-textdecoder-fatal.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,15 @@ bad.forEach((t) => {
assert(!new TextDecoder().fatal);
assert(new TextDecoder('utf-8', { fatal: true }).fatal);
}

{
const notArrayBufferViewExamples = [false, {}, 1, '', new Error()];
notArrayBufferViewExamples.forEach((invalidInputType) => {
common.expectsError(() => {
new TextDecoder(undefined, null).decode(invalidInputType);
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
});
});
}
8 changes: 8 additions & 0 deletions test/parallel/test-whatwg-encoding-textdecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ if (common.hasIntl) {
});
}

// Test TextDecoder, label undefined, options null
{
const dec = new TextDecoder(undefined, null);
assert.strictEqual(dec.encoding, 'utf-8');
assert.strictEqual(dec.fatal, false);
assert.strictEqual(dec.ignoreBOM, false);
}

// Test TextDecoder, UTF-16le
{
const dec = new TextDecoder('utf-16le');
Expand Down

0 comments on commit e21d784

Please sign in to comment.