Browse Source

test: writable stream finished state

Add a test for _writableState.finished.

PR-URL: https://github.com/nodejs/node/pull/8791
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Related: https://github.com/nodejs/node/issues/8686
v7.x
Italo A. Casas 8 years ago
committed by Evan Lucas
parent
commit
d6f688ae0d
  1. 22
      test/parallel/test-stream-writable-finished-state.js

22
test/parallel/test-stream-writable-finished-state.js

@ -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);
}));
Loading…
Cancel
Save