Skip to content

Commit f64d93f

Browse files
italoacasasMylesBorins
authored andcommitted
test: writable stream finished state
Add a test for _writableState.finished. PR-URL: #8791 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Related: #8686
1 parent 210ae56 commit f64d93f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
const assert = require('assert');
6+
const stream = require('stream');
7+
8+
const writable = new stream.Writable();
9+
10+
writable._write = (chunk, encoding, cb) => {
11+
// The state finished should start in false.
12+
assert.strictEqual(writable._writableState.finished, false);
13+
cb();
14+
};
15+
16+
writable.on('finish', common.mustCall(() => {
17+
assert.strictEqual(writable._writableState.finished, true);
18+
}));
19+
20+
writable.end('testing finished state', common.mustCall(() => {
21+
assert.strictEqual(writable._writableState.finished, true);
22+
}));

0 commit comments

Comments
 (0)