Skip to content

Commit fed96f5

Browse files
committed
test: test streambase already has a consumer
1 parent 6b599a3 commit fed96f5

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

test/parallel/test-whatwg-webstreams-adapters-streambase.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ const {
6565
const readable = newReadableStreamFromStreamBase(stream);
6666
readable.cancel().then(common.mustCall());
6767
}
68+
69+
{
70+
const stream = new JSStream();
71+
stream.onread = () => {};
72+
assert.throws(() => newReadableStreamFromStreamBase(stream), {
73+
code: 'ERR_INVALID_STATE',
74+
message: /StreamBase already has a consumer/
75+
});
76+
stream.emitEOF();
77+
}

test/parallel/test-whatwg-webstreams-adapters-to-readablewritablepair.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,10 @@ const {
248248
reader.closed.then(common.mustCall());
249249
writer.close().then(common.mustCall());
250250
}
251+
252+
{
253+
assert.throws(() => newReadableWritablePairFromDuplex(null), {
254+
code: 'ERR_INVALID_ARG_TYPE',
255+
message: /The "duplex" argument must be an stream\.Duplex/
256+
});
257+
}

test/parallel/test-whatwg-webstreams-adapters-to-streamduplex.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,23 @@ const {
164164

165165
duplex.end();
166166
}
167+
168+
{
169+
const transform = { readable: {}, writable: {} };
170+
assert.throws(() => newStreamDuplexFromReadableWritablePair(transform), {
171+
code: 'ERR_INVALID_ARG_TYPE',
172+
message: /The "pair\.readable" property must be an instance of ReadableStream/
173+
});
174+
}
175+
176+
{
177+
const transform = {
178+
readable: new ReadableStream(),
179+
writable: null
180+
};
181+
182+
assert.throws(() => newStreamDuplexFromReadableWritablePair(transform), {
183+
code: 'ERR_INVALID_ARG_TYPE',
184+
message: /The "pair\.writable" property must be an instance of WritableStream/
185+
});
186+
}

0 commit comments

Comments
 (0)