镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions test/parallel/test-stream-promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,30 @@ assert.strictEqual(finished, promisify(stream.finished));
{
const streamObj = new Writable();
assert.strictEqual(streamObj.listenerCount('end'), 0);
finished(streamObj, { cleanup: false }).then(() => {
finished(streamObj, { cleanup: false }).then(common.mustCall(() => {
assert.strictEqual(streamObj.listenerCount('end'), 1);
});
}));
streamObj.end();
}

// Cleanup function should be called when cleanup is set to true
// listenerCount should be 0 after calling finish
{
const streamObj = new Writable();
assert.strictEqual(streamObj.listenerCount('end'), 0);
finished(streamObj, { cleanup: true }).then(() => {
finished(streamObj, { cleanup: true }).then(common.mustCall(() => {
assert.strictEqual(streamObj.listenerCount('end'), 0);
});
}));
streamObj.end();
}

// Cleanup function should not be called when cleanup has not been set
// listenerCount should be 1 after calling finish
{
const streamObj = new Writable();
assert.strictEqual(streamObj.listenerCount('end'), 0);
finished(streamObj).then(() => {
finished(streamObj).then(common.mustCall(() => {
assert.strictEqual(streamObj.listenerCount('end'), 1);
});
}));
streamObj.end();
}