Skip to content

Commit 80a26c7

Browse files
Italo A. CasasMyles Borins
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 f9baa11 commit 80a26c7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict';
2+
3+
constcommon=require('../common');
4+
5+
constassert=require('assert');
6+
conststream=require('stream');
7+
8+
constwritable=newstream.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)