diff options
author | Yoshiki Kurihara <yosyos0306@gmail.com> | 2022-05-05 14:48:55 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 14:48:55 +0300 |
commit | 5ef83bab6f3054c31d306f68a3c8f75957023ac6 (patch) | |
tree | f5a0427f42e97319e5e95e75979170121853e9ba | |
parent | a571a3fed1f417be849d4011a8e76e39e99de0d8 (diff) |
test: validate webstream encoder/decoder inspector
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 <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>
-rw-r--r-- | test/parallel/test-webstream-encoding-inspect.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/parallel/test-webstream-encoding-inspect.js b/test/parallel/test-webstream-encoding-inspect.js new file mode 100644 index 00000000000..69c947ebc6d --- /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', +}); |