Skip to content

Commit

Permalink
test: validate websteam encoder/decoder inpector
Browse files Browse the repository at this point in the history
  • Loading branch information
kuriyosh committed Apr 15, 2022
1 parent 24adba6 commit b635acf
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 b635acf

Please sign in to comment.