Skip to content

Commit

Permalink
test: improve code coverage for streams/duplexify
Browse files Browse the repository at this point in the history
  • Loading branch information
ErickWendel committed Apr 19, 2022
1 parent 6847fec commit 7fd01a6
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions test/parallel/test-stream-duplex-from.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,20 @@ const { Blob } = require('buffer');

// Ensure that given readable stream that throws an error it calls destroy
{
const myErrorMessage = 'error!';
const duplex = Duplex.from(Readable({
read() {
throw new Error(myErrorMessage);
}
}));
duplex.on('error', common.mustCall((msg) => {
assert.strictEqual(msg.message, myErrorMessage);
}));
// As throwing exceptions on readable streams works only for Node v17+
// Ignoring this test on older versions
const isv16Higher = parseInt(process.versions.node.match(/\d{2}/)) > 16;
if (isv16Higher) {
const myErrorMessage = 'error!';
const duplex = Duplex.from(Readable({
read() {
throw new Error(myErrorMessage);
}
}));
duplex.on('error', common.mustCall((msg) => {
assert.strictEqual(msg.message, myErrorMessage);
}));
}
}

// Ensure that given writable stream that throws an error it calls destroy
Expand Down

0 comments on commit 7fd01a6

Please sign in to comment.