Skip to content

Commit 701604e

Browse files
committed
test: fix test expectations
1 parent e74c6fe commit 701604e

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,34 @@ assert(TextDecoder);
6767
}
6868

6969
// Test TextDecoder, UTF-8, fatal: true, ignoreBOM: false
70-
if (common.hasIntl) {
71-
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
72-
const dec = new TextDecoder(i, { fatal: true });
73-
assert.throws(() => dec.decode(buf.slice(0, 8)),
74-
{
75-
code: 'ERR_ENCODING_INVALID_ENCODED_DATA',
76-
name: 'TypeError',
77-
message: 'The encoded data was not valid ' +
78-
'for encoding utf-8'
79-
});
80-
});
81-
82-
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
83-
const dec = new TextDecoder(i, { fatal: true });
70+
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
71+
const dec = new TextDecoder(i, { fatal: true });
72+
assert.throws(() => dec.decode(buf.slice(0, 8)),
73+
{
74+
code: 'ERR_ENCODING_INVALID_ENCODED_DATA',
75+
name: 'TypeError',
76+
message: 'The encoded data was not valid ' +
77+
'for encoding utf-8'
78+
});
79+
});
80+
81+
['unicode-1-1-utf-8', 'utf8', 'utf-8'].forEach((i) => {
82+
const dec = new TextDecoder(i, { fatal: true });
83+
if (common.hasIntl) {
8484
dec.decode(buf.slice(0, 8), { stream: true });
8585
dec.decode(buf.slice(8));
86-
});
87-
} else {
88-
assert.throws(
89-
() => new TextDecoder('utf-8', { fatal: true }),
90-
{
91-
code: 'ERR_NO_ICU',
92-
name: 'TypeError',
93-
message: '"fatal" option is not supported on Node.js compiled without ICU'
94-
});
95-
}
86+
} else {
87+
assert.throws(
88+
() => {
89+
dec.decode(buf.slice(0, 8), { stream: true });
90+
},
91+
{
92+
code: 'ERR_NO_ICU',
93+
name: 'TypeError',
94+
message: '"fatal" option is not supported on Node.js compiled without ICU'
95+
});
96+
}
97+
});
9698

9799
// Test TextDecoder, label undefined, options null
98100
{

0 commit comments

Comments
 (0)