Skip to content

Commit d23debb

Browse files
kuriyoshRafaelGSS
authored andcommitted
test: validate webstream encoder/decoder inspector
PR-URL: #42747 Refs: https://coverage.nodejs.org/coverage-24adba675179ebba/lib/internal/webstreams/encoding.js.html#L98 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Mestery <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent b1c18ed commit d23debb

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
'use strict';
2+
3+
require('../common');
4+
5+
const { TextEncoderStream, TextDecoderStream } = require('stream/web');
6+
const util = require('util');
7+
const assert = require('assert');
8+
9+
const textEncoderStream = new TextEncoderStream();
10+
assert.strictEqual(
11+
util.inspect(textEncoderStream),
12+
`TextEncoderStream {
13+
encoding: 'utf-8',
14+
readable: ReadableStream { locked: false, state: 'readable', supportsBYOB: false },
15+
writable: WritableStream { locked: false, state: 'writable' }
16+
}`
17+
);
18+
assert.throws(() => textEncoderStream[util.inspect.custom].call(), {
19+
code: 'ERR_INVALID_THIS',
20+
});
21+
22+
const textDecoderStream = new TextDecoderStream();
23+
assert.strictEqual(
24+
util.inspect(textDecoderStream),
25+
`TextDecoderStream {
26+
encoding: 'utf-8',
27+
fatal: false,
28+
ignoreBOM: false,
29+
readable: ReadableStream { locked: false, state: 'readable', supportsBYOB: false },
30+
writable: WritableStream { locked: false, state: 'writable' }
31+
}`
32+
);
33+
assert.throws(() => textDecoderStream[util.inspect.custom].call(), {
34+
code: 'ERR_INVALID_THIS',
35+
});

0 commit comments

Comments
 (0)