Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Mar 22, 2015
1 parent 0011c68 commit bd4daca
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/parallel/test-stream2-writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,25 @@ test('finish is emitted if last chunk is empty', function(t) {
w.write(Buffer(1));
w.end(Buffer(0));
});

test('finish is emitted after shutdown', function(t) {
var w = new W();
var shutdown = false;

w._writableState._end = function (stream, cb) {
assert(stream === w);
setTimeout(function() {
shutdown = true;
cb();
}, 100);
};
w._write = function(chunk, e, cb) {
process.nextTick(cb);
};
w.on('finish', function() {
assert(shutdown);
t.end();
});
w.write(Buffer(1));
w.end(Buffer(0));
});

0 comments on commit bd4daca

Please sign in to comment.