0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-stream-writable-finished-state.js
Italo A. Casas f12338ddb0 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
2016-10-28 08:50:44 +02:00

23 lines
574 B
JavaScript

'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);
}));