Skip to content

Commit

Permalink
test: validate webstream encoder/decoder inspector
Browse files Browse the repository at this point in the history
PR-URL: #42747
Refs: https://coverage.nodejs.org/coverage-24adba675179ebba/lib/internal/webstreams/encoding.js.html#L98
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
kuriyosh authored and RafaelGSS committed May 10, 2022
1 parent b1c18ed commit d23debb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/parallel/test-webstream-encoding-inspect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
'use strict';

require('../common');

const { TextEncoderStream, TextDecoderStream } = require('stream/web');
const util = require('util');
const assert = require('assert');

const textEncoderStream = new TextEncoderStream();
assert.strictEqual(
util.inspect(textEncoderStream),
`TextEncoderStream {
encoding: 'utf-8',
readable: ReadableStream { locked: false, state: 'readable', supportsBYOB: false },
writable: WritableStream { locked: false, state: 'writable' }
}`
);
assert.throws(() => textEncoderStream[util.inspect.custom].call(), {
code: 'ERR_INVALID_THIS',
});

const textDecoderStream = new TextDecoderStream();
assert.strictEqual(
util.inspect(textDecoderStream),
`TextDecoderStream {
encoding: 'utf-8',
fatal: false,
ignoreBOM: false,
readable: ReadableStream { locked: false, state: 'readable', supportsBYOB: false },
writable: WritableStream { locked: false, state: 'writable' }
}`
);
assert.throws(() => textDecoderStream[util.inspect.custom].call(), {
code: 'ERR_INVALID_THIS',
});

0 comments on commit d23debb

Please sign in to comment.