Skip to content

Commit 49e5f47

Browse files
MrJithilUlisesGascon
authored andcommitted
test: test streambase has already has a consumer
test: test streambase has already has a consumer PR-URL: #48059 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6f46d31 commit 49e5f47

3 files changed

+33
-0
lines changed

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

+9
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,12 @@ const {
6565
const readable = newReadableStreamFromStreamBase(stream);
6666
readable.cancel().then(common.mustCall());
6767
}
68+
69+
{
70+
const stream = new JSStream();
71+
stream.onread = common.mustCall();
72+
assert.throws(() => newReadableStreamFromStreamBase(stream), {
73+
code: 'ERR_INVALID_STATE'
74+
});
75+
stream.emitEOF();
76+
}

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

+6
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,9 @@ 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+
});
256+
}

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

+18
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,21 @@ 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+
});
173+
}
174+
175+
{
176+
const transform = {
177+
readable: new ReadableStream(),
178+
writable: null
179+
};
180+
181+
assert.throws(() => newStreamDuplexFromReadableWritablePair(transform), {
182+
code: 'ERR_INVALID_ARG_TYPE',
183+
});
184+
}

0 commit comments

Comments
 (0)