Skip to content

Commit 60f1a5a

Browse files
lrdcasimirMylesBorins
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 <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent f5c68dc commit 60f1a5a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/parallel/test-stream-finished.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,25 @@ const { promisify } = require('util');
119119
rs.push(null);
120120
rs.resume();
121121
}
122+
123+
// Test that calling returned function removes listeners
124+
{
125+
const ws = new Writable({
126+
write(data, env, cb) {
127+
cb();
128+
}
129+
});
130+
const removeListener = finished(ws, common.mustNotCall());
131+
removeListener();
132+
ws.end();
133+
}
134+
135+
{
136+
const rs = new Readable();
137+
const removeListeners = finished(rs, common.mustNotCall());
138+
removeListeners();
139+
140+
rs.emit('close');
141+
rs.push(null);
142+
rs.resume();
143+
}

0 commit comments

Comments
 (0)