Skip to content

Commit 086ee5e

Browse files
lrdcasimirtargos
authored andcommitted
test: increase coverage of internal/stream/end-of-stream
This change adds test cases to call the function returned by end-of-stream and asserts that callbacks are not called when the stream is ended, or prematurely closed. PR-URL: #23751 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 1baba9b commit 086ee5e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/parallel/test-stream-finished.js

+22
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,25 @@ const { promisify } = require('util');
153153
rs.push(null);
154154
rs.resume();
155155
}
156+
157+
// Test that calling returned function removes listeners
158+
{
159+
const ws = new Writable({
160+
write(data, env, cb) {
161+
cb();
162+
}
163+
});
164+
const removeListener = finished(ws, common.mustNotCall());
165+
removeListener();
166+
ws.end();
167+
}
168+
169+
{
170+
const rs = new Readable();
171+
const removeListeners = finished(rs, common.mustNotCall());
172+
removeListeners();
173+
174+
rs.emit('close');
175+
rs.push(null);
176+
rs.resume();
177+
}

0 commit comments

Comments
 (0)