Skip to content

Commit

Permalink
test: writable stream finished state
Browse files Browse the repository at this point in the history
Add a test for _writableState.finished.

PR-URL: #8791
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Related: #8686
  • Loading branch information
italoacasas authored and Myles Borins committed Nov 17, 2016
1 parent f9baa11 commit 80a26c7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/parallel/test-stream-writable-finished-state.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const common = require('../common');

const assert = require('assert');
const stream = require('stream');

const writable = new stream.Writable();

writable._write = (chunk, encoding, cb) => {
// The state finished should start in false.
assert.strictEqual(writable._writableState.finished, false);
cb();
};

writable.on('finish', common.mustCall(() => {
assert.strictEqual(writable._writableState.finished, true);
}));

writable.end('testing finished state', common.mustCall(() => {
assert.strictEqual(writable._writableState.finished, true);
}));

0 comments on commit 80a26c7

Please sign in to comment.