Skip to content

Commit

Permalink
test: test streambase already has a consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
MrJithil committed May 18, 2023
1 parent 05693ac commit d0aeccf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/parallel/test-whatwg-webstreams-adapters-streambase.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ const {
const readable = newReadableStreamFromStreamBase(stream);
readable.cancel().then(common.mustCall());
}

{
const stream = new JSStream();
stream.onread = () => {};
assert.throws(() => newReadableStreamFromStreamBase(stream), {
code: 'ERR_INVALID_STATE',
message: /StreamBase already has a consumer/
});
stream.emitEOF();
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,10 @@ const {
reader.closed.then(common.mustCall());
writer.close().then(common.mustCall());
}

{
assert.throws(() => newReadableWritablePairFromDuplex(null), {
code: 'ERR_INVALID_ARG_TYPE',
message: /The "duplex" argument must be an stream\.Duplex/
});
}
20 changes: 20 additions & 0 deletions test/parallel/test-whatwg-webstreams-adapters-to-streamduplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,23 @@ const {

duplex.end();
}

{
const transform = { readable: {}, writable: {} };
assert.throws(() => newStreamDuplexFromReadableWritablePair(transform), {
code: 'ERR_INVALID_ARG_TYPE',
message: /The "pair\.readable" property must be an instance of ReadableStream/
});
}

{
const transform = {
readable: new ReadableStream(),
writable: null
};

assert.throws(() => newStreamDuplexFromReadableWritablePair(transform), {
code: 'ERR_INVALID_ARG_TYPE',
message: /The "pair\.writable" property must be an instance of WritableStream/
});
}

0 comments on commit d0aeccf

Please sign in to comment.