mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
f12338ddb0
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
23 lines
574 B
JavaScript
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);
|
|
}));
|