mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: refactor test-whatwg-webstreams-encoding to be shorter
PR-URL: https://github.com/nodejs/node/pull/54569 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
parent
c8c108f9b0
commit
291d90acbc
@ -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}`)
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
@ -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}`)
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user