Skip to content

Commit

Permalink
Added unit test for close event
Browse files Browse the repository at this point in the history
  • Loading branch information
Drian Naude committed Nov 17, 2021
1 parent 3487682 commit bcef2bb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/unit/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ describe('Input/output', function () {
readable.pipe(pipeline).pipe(writable);
});

it('Stream should emit close event', function (done) {
const readable = fs.createReadStream(fixtures.inputJpg);
const writable = fs.createWriteStream(outputJpg);
const pipeline = sharp().resize(320, 240);
let closeEventEmitted = false;
pipeline.on('close', function () {
closeEventEmitted = pipeline._readableState.closeEmitted;
});
writable.on('close', function () {
assert.strictEqual(true, closeEventEmitted);
rimraf(outputJpg, done);
});
readable.pipe(pipeline).pipe(writable);
});

it('Handle Stream to Stream error ', function (done) {
const pipeline = sharp().resize(320, 240);
let anErrorWasEmitted = false;
Expand Down

0 comments on commit bcef2bb

Please sign in to comment.