diff --git a/lib/internal/webstreams/compression.js b/lib/internal/webstreams/compression.js index ac10d093dcefcc..2299b9c49e05bd 100644 --- a/lib/internal/webstreams/compression.js +++ b/lib/internal/webstreams/compression.js @@ -78,7 +78,7 @@ class CompressionStream { } [kInspect](depth, options) { - customInspect(depth, options, 'CompressionStream', { + return customInspect(depth, options, 'CompressionStream', { readable: this.#transform.readable, writable: this.#transform.writable, }); @@ -128,7 +128,7 @@ class DecompressionStream { } [kInspect](depth, options) { - customInspect(depth, options, 'DecompressionStream', { + return customInspect(depth, options, 'DecompressionStream', { readable: this.#transform.readable, writable: this.#transform.writable, }); diff --git a/test/parallel/test-compression-decompression-stream.js b/test/parallel/test-compression-decompression-stream.js new file mode 100644 index 00000000000000..69e7cc625f421e --- /dev/null +++ b/test/parallel/test-compression-decompression-stream.js @@ -0,0 +1,41 @@ +// Flags: --no-warnings --expose-internals +'use strict'; + +require('../common'); + +const assert = require('assert'); +const { describe, it } = require('node:test'); +const { + CompressionStream, + DecompressionStream, +} = require('stream/web'); + +const { + customInspectSymbol: kInspect, +} = require('internal/util'); + +describe('DecompressionStream kInspect method', () => { + it('should return a predictable inspection string with DecompressionStream', () => { + const decompressionStream = new DecompressionStream('deflate'); + const depth = 1; + const options = {}; + const actual = decompressionStream[kInspect](depth, options); + + assert(actual.includes('DecompressionStream')); + assert(actual.includes('ReadableStream')); + assert(actual.includes('WritableStream')); + }); +}); + +describe('CompressionStream kInspect method', () => { + it('should return a predictable inspection string with CompressionStream', () => { + const compressionStream = new CompressionStream('deflate'); + const depth = 1; + const options = {}; + const actual = compressionStream[kInspect](depth, options); + + assert(actual.includes('CompressionStream')); + assert(actual.includes('ReadableStream')); + assert(actual.includes('WritableStream')); + }); +});