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
PR-URL: #54569
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
hidaviddong authored Sep 19, 2024
1 parent c8c108f commit 291d90a
Showing 1 changed file with 18 additions and 42 deletions.
60 changes: 18 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,15 @@ 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/,
stack: new RegExp(`at get ${getter}`)
}
);
});
}

{
Expand All @@ -91,20 +74,13 @@ 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/,
stack: new RegExp(`at get ${getter}`)
}
);
});
}

0 comments on commit 291d90a

Please sign in to comment.