Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 086ee5e

Browse filesBrowse 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
Copy full SHA for 086ee5e

File tree

Expand file treeCollapse file tree

1 file changed

+22
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-0
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-stream-finished.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-stream-finished.js
+22Lines changed: 22 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.