From eb46e09570c9262ccf97e3b11c2ad52de29a3a37 Mon Sep 17 00:00:00 2001 From: Jithil P Ponnan Date: Thu, 18 May 2023 23:37:57 +1000 Subject: [PATCH] test: test streambase has already has a consumer test: test streambase has already has a consumer PR-URL: https://github.com/nodejs/node/pull/48059 Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell --- ...st-whatwg-webstreams-adapters-streambase.js | 9 +++++++++ ...streams-adapters-to-readablewritablepair.js | 6 ++++++ ...atwg-webstreams-adapters-to-streamduplex.js | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/test/parallel/test-whatwg-webstreams-adapters-streambase.js b/test/parallel/test-whatwg-webstreams-adapters-streambase.js index 43d28f0499dc7d..bd864ab8c14195 100644 --- a/test/parallel/test-whatwg-webstreams-adapters-streambase.js +++ b/test/parallel/test-whatwg-webstreams-adapters-streambase.js @@ -65,3 +65,12 @@ const { const readable = newReadableStreamFromStreamBase(stream); readable.cancel().then(common.mustCall()); } + +{ + const stream = new JSStream(); + stream.onread = common.mustCall(); + assert.throws(() => newReadableStreamFromStreamBase(stream), { + code: 'ERR_INVALID_STATE' + }); + stream.emitEOF(); +} diff --git a/test/parallel/test-whatwg-webstreams-adapters-to-readablewritablepair.js b/test/parallel/test-whatwg-webstreams-adapters-to-readablewritablepair.js index 83d21247a49265..5062b9e179ac1e 100644 --- a/test/parallel/test-whatwg-webstreams-adapters-to-readablewritablepair.js +++ b/test/parallel/test-whatwg-webstreams-adapters-to-readablewritablepair.js @@ -248,3 +248,9 @@ const { reader.closed.then(common.mustCall()); writer.close().then(common.mustCall()); } + +{ + assert.throws(() => newReadableWritablePairFromDuplex(null), { + code: 'ERR_INVALID_ARG_TYPE' + }); +} diff --git a/test/parallel/test-whatwg-webstreams-adapters-to-streamduplex.js b/test/parallel/test-whatwg-webstreams-adapters-to-streamduplex.js index 15ac9f832714e9..9c92a4778a00fd 100644 --- a/test/parallel/test-whatwg-webstreams-adapters-to-streamduplex.js +++ b/test/parallel/test-whatwg-webstreams-adapters-to-streamduplex.js @@ -164,3 +164,21 @@ const { duplex.end(); } + +{ + const transform = { readable: {}, writable: {} }; + assert.throws(() => newStreamDuplexFromReadableWritablePair(transform), { + code: 'ERR_INVALID_ARG_TYPE' + }); +} + +{ + const transform = { + readable: new ReadableStream(), + writable: null + }; + + assert.throws(() => newStreamDuplexFromReadableWritablePair(transform), { + code: 'ERR_INVALID_ARG_TYPE', + }); +}