Skip to content

Commit 8bb7f56

Browse files
fossamagnajuanarbol
authored andcommitted
test: improve lib/internal/webstreams/readablestream.js coverage
PR-URL: #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>
1 parent d9156c9 commit 8bb7f56

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

‎test/parallel/test-whatwg-readablebytestream.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ const {
6565
defaultReader.releaseLock();
6666
constbyobReader=r.getReader({mode: 'byob'});
6767
assert(byobReaderinstanceofReadableStreamBYOBReader);
68+
assert.match(
69+
inspect(byobReader,{depth: 0}),
70+
/ReadableStreamBYOBReader/);
6871
}
6972

7073
classSource{
@@ -233,6 +236,19 @@ class Source {
233236
});
234237
}
235238

239+
{
240+
letcontroller;
241+
newReadableStream({
242+
type: 'bytes',
243+
start(c){controller=c;}
244+
});
245+
controller.enqueue(newUint8Array(10));
246+
controller.close();
247+
assert.throws(()=>controller.enqueue(newUint8Array(10)),{
248+
code: 'ERR_INVALID_STATE',
249+
});
250+
}
251+
236252
{
237253
conststream=newReadableStream({
238254
type: 'bytes',

‎test/parallel/test-whatwg-readablestream.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const {
3232
readableStreamDefaultControllerCanCloseOrEnqueue,
3333
readableByteStreamControllerClose,
3434
readableByteStreamControllerRespond,
35+
readableStreamReaderGenericRelease,
3536
}=require('internal/webstreams/readablestream');
3637

3738
const{
@@ -371,6 +372,24 @@ assert.throws(() => {
371372
});
372373
}
373374

375+
{
376+
conststream=newReadableStream();
377+
constiterable=stream.values();
378+
readableStreamReaderGenericRelease(stream[kState].reader);
379+
assert.rejects(iterable.next(),{
380+
code: 'ERR_INVALID_STATE',
381+
}).then(common.mustCall());
382+
}
383+
384+
{
385+
conststream=newReadableStream();
386+
constiterable=stream.values();
387+
readableStreamReaderGenericRelease(stream[kState].reader);
388+
assert.rejects(iterable.return(),{
389+
code: 'ERR_INVALID_STATE',
390+
}).then(common.mustCall());
391+
}
392+
374393
{
375394
conststream=newReadableStream({
376395
start(controller){
@@ -1357,6 +1376,9 @@ class Source {
13571376
assert.throws(()=>ReadableStream.prototype.tee.call({}),{
13581377
code: 'ERR_INVALID_THIS',
13591378
});
1379+
assert.throws(()=>ReadableStream.prototype.values.call({}),{
1380+
code: 'ERR_INVALID_THIS',
1381+
});
13601382
assert.throws(()=>ReadableStream.prototype[kTransfer].call({}),{
13611383
code: 'ERR_INVALID_THIS',
13621384
});

0 commit comments

Comments
 (0)