Skip to content

Commit

Permalink
test: refactor test-whatwg-webstreams-encoding to be shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
hidaviddong committed Aug 26, 2024
1 parent 4ce9864 commit 07a43f7
Showing 1 changed file with 12 additions and 42 deletions.
54 changes: 12 additions & 42 deletions test/parallel/test-whatwg-webstreams-encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,12 @@ const kEuro = Buffer.from([0xe2, 0x82, 0xac]).toString();
assert.strictEqual(tds.encoding, 'utf-8');
assert.strictEqual(tds.fatal, false);
assert.strictEqual(tds.ignoreBOM, false);

assert.throws(
() => Reflect.get(TextDecoderStream.prototype, 'encoding', {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
assert.throws(
() => Reflect.get(TextDecoderStream.prototype, 'fatal', {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
assert.throws(
() => Reflect.get(TextDecoderStream.prototype, 'ignoreBOM', {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
assert.throws(
() => Reflect.get(TextDecoderStream.prototype, 'readable', {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
assert.throws(
() => Reflect.get(TextDecoderStream.prototype, 'writable', {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
['encoding', 'fatal', 'ignoreBOM', 'readable', 'writable'].forEach((getter) => {
assert.throws(
() => Reflect.get(TextDecoderStream.prototype, getter, {}),
{ name: 'TypeError', message: /Cannot read private member/ }
)
});
}

{
Expand All @@ -91,20 +71,10 @@ const kEuro = Buffer.from([0xe2, 0x82, 0xac]).toString();
]).then(common.mustCall());

assert.strictEqual(tds.encoding, 'utf-8');

assert.throws(
() => Reflect.get(TextEncoderStream.prototype, 'encoding', {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
assert.throws(
() => Reflect.get(TextEncoderStream.prototype, 'readable', {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
assert.throws(
() => Reflect.get(TextEncoderStream.prototype, 'writable', {}), {
name: 'TypeError',
message: /Cannot read private member/,
});
['encoding', 'readable', 'writable'].forEach((getter) => {
assert.throws(
() => Reflect.get(TextDecoderStream.prototype, getter, {}),
{ name: 'TypeError', message: /Cannot read private member/ }
)
});
}

0 comments on commit 07a43f7

Please sign in to comment.