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: nodejs#23751
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
lrdcasimir authored and addaleax committed Oct 24, 2018
1 parent cc750b7 commit 7d2494d
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 7d2494d

Please sign in to comment.