From abafda8e956ccddd5d81fd4b8ba2a04ea74b317c Mon Sep 17 00:00:00 2001 From: Yoshiki Kurihara Date: Thu, 5 May 2022 20:48:55 +0900 Subject: [PATCH] test: validate webstream encoder/decoder inspector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/42747 Refs: https://coverage.nodejs.org/coverage-24adba675179ebba/lib/internal/webstreams/encoding.js.html#L98 Reviewed-By: James M Snell Reviewed-By: Darshan Sen Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen Reviewed-By: Mestery Reviewed-By: Antoine du Hamel --- .../test-webstream-encoding-inspect.js | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/parallel/test-webstream-encoding-inspect.js diff --git a/test/parallel/test-webstream-encoding-inspect.js b/test/parallel/test-webstream-encoding-inspect.js new file mode 100644 index 00000000000000..69c947ebc6d990 --- /dev/null +++ b/test/parallel/test-webstream-encoding-inspect.js @@ -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', +});