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
This commit is contained in:
parent
6893f3cc10
commit
f12338ddb0
22
test/parallel/test-stream-writable-finished-state.js
Normal file
22
test/parallel/test-stream-writable-finished-state.js
Normal file
@ -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…
x
Reference in New Issue
Block a user