Skip to content

Commit

Permalink
test: increase coverage of internal/stream/end-of-stream
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
lrdcasimir authored and targos committed Oct 24, 2018
1 parent 1baba9b commit 086ee5e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,25 @@ const { promisify } = require('util');
rs.push(null);
rs.resume();
}

// Test that calling returned function removes listeners
{
const ws = new Writable({
write(data, env, cb) {
cb();
}
});
const removeListener = finished(ws, common.mustNotCall());
removeListener();
ws.end();
}

{
const rs = new Readable();
const removeListeners = finished(rs, common.mustNotCall());
removeListeners();

rs.emit('close');
rs.push(null);
rs.resume();
}

0 comments on commit 086ee5e

Please sign in to comment.