diff options
author | MURAKAMI Masahiko <m-murakami@esm.co.jp> | 2022-05-05 14:48:37 +0300 |
---|---|---|
committer | RafaelGSS <rafael.nunu@hotmail.com> | 2022-05-10 15:13:18 +0300 |
commit | 2dc795687a8477bacfe686adaa5a644fd8bebcf2 (patch) | |
tree | 614b773d6658fd5da296390e3f001fb638d11152 /test | |
parent | a20310d171aea18accf93ade3d60234944ba6c54 (diff) |
test: improve `lib/internal/webstreams/readablestream.js` coverage
PR-URL: https://github.com/nodejs/node/pull/42823
Refs: https://coverage.nodejs.org/coverage-3a6b975981092213/lib/internal/webstreams/readablestream.js.html#L421
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-whatwg-readablebytestream.js | 16 | ||||
-rw-r--r-- | test/parallel/test-whatwg-readablestream.js | 22 |
2 files changed, 38 insertions, 0 deletions
diff --git a/test/parallel/test-whatwg-readablebytestream.js b/test/parallel/test-whatwg-readablebytestream.js index 83ec85fae61..6b305a0d836 100644 --- a/test/parallel/test-whatwg-readablebytestream.js +++ b/test/parallel/test-whatwg-readablebytestream.js @@ -65,6 +65,9 @@ const { defaultReader.releaseLock(); const byobReader = r.getReader({ mode: 'byob' }); assert(byobReader instanceof ReadableStreamBYOBReader); + assert.match( + inspect(byobReader, { depth: 0 }), + /ReadableStreamBYOBReader/); } class Source { @@ -234,6 +237,19 @@ class Source { } { + let controller; + new ReadableStream({ + type: 'bytes', + start(c) { controller = c; } + }); + controller.enqueue(new Uint8Array(10)); + controller.close(); + assert.throws(() => controller.enqueue(new Uint8Array(10)), { + code: 'ERR_INVALID_STATE', + }); +} + +{ const stream = new ReadableStream({ type: 'bytes', pull(c) { diff --git a/test/parallel/test-whatwg-readablestream.js b/test/parallel/test-whatwg-readablestream.js index cef3eca6ed2..1bb53d5286c 100644 --- a/test/parallel/test-whatwg-readablestream.js +++ b/test/parallel/test-whatwg-readablestream.js @@ -32,6 +32,7 @@ const { readableStreamDefaultControllerCanCloseOrEnqueue, readableByteStreamControllerClose, readableByteStreamControllerRespond, + readableStreamReaderGenericRelease, } = require('internal/webstreams/readablestream'); const { @@ -372,6 +373,24 @@ assert.throws(() => { } { + const stream = new ReadableStream(); + const iterable = stream.values(); + readableStreamReaderGenericRelease(stream[kState].reader); + assert.rejects(iterable.next(), { + code: 'ERR_INVALID_STATE', + }).then(common.mustCall()); +} + +{ + const stream = new ReadableStream(); + const iterable = stream.values(); + readableStreamReaderGenericRelease(stream[kState].reader); + assert.rejects(iterable.return(), { + code: 'ERR_INVALID_STATE', + }).then(common.mustCall()); +} + +{ const stream = new ReadableStream({ start(controller) { controller.enqueue(Buffer.from('hello')); @@ -1357,6 +1376,9 @@ class Source { assert.throws(() => ReadableStream.prototype.tee.call({}), { code: 'ERR_INVALID_THIS', }); + assert.throws(() => ReadableStream.prototype.values.call({}), { + code: 'ERR_INVALID_THIS', + }); assert.throws(() => ReadableStream.prototype[kTransfer].call({}), { code: 'ERR_INVALID_THIS', }); |