-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test for _writableState.ending, when ending becomes true, but the stream is not finished/ended yet. PR-URL: #8707 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Related: #8686
- Loading branch information
1 parent
d6f688a
commit 248a320
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
const assert = require('assert'); | ||
const stream = require('stream'); | ||
|
||
const writable = new stream.Writable(); | ||
|
||
function testStates(ending, finished, ended) { | ||
assert.strictEqual(writable._writableState.ending, ending); | ||
assert.strictEqual(writable._writableState.finished, finished); | ||
assert.strictEqual(writable._writableState.ended, ended); | ||
} | ||
|
||
writable._write = (chunk, encoding, cb) => { | ||
// ending, finished, ended start in false. | ||
testStates(false, false, false); | ||
cb(); | ||
}; | ||
|
||
writable.on('finish', () => { | ||
// ending, finished, ended = true. | ||
testStates(true, true, true); | ||
}); | ||
|
||
writable.end('testing function end()', () => { | ||
// ending, finished, ended = true. | ||
testStates(true, true, true); | ||
}); | ||
|
||
// ending, ended = true. | ||
// finished = false. | ||
testStates(true, false, true); |