-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Streams: add test for _readableState.readingMore | #8685 #9868
Changes from 2 commits
19432ad
370674a
9747c04
395368e
1968956
71ebbbc
1e6428e
a655f4c
466c083
2973949
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
const Readable = require('stream').Readable, | ||
assert = require('assert'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use a new |
||
|
||
const readable = new Readable({ | ||
read(size) {} | ||
}); | ||
|
||
// false initially | ||
assert.strictEqual(readable._readableState.readingMore, false); | ||
|
||
readable.on('data', data => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since there are assertions inside of this callback, can you wrap it in |
||
// still in a flowing state, try to read more | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please capitalize and punctuate comments. |
||
assert.strictEqual(readable._readableState.readingMore, true); | ||
}); | ||
|
||
readable.on('end', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment about |
||
// end of stream | ||
// reading is false, and so should be readingMore | ||
assert.strictEqual(readable._readableState.readingMore, false); | ||
}); | ||
|
||
|
||
readable.push("abc"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use single quotes for strings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cjihrig Thank you for the guidance 👍 |
||
readable.push(null); | ||
|
||
process.nextTick(() => { | ||
// finished reading | ||
// reading is false, and so should be readingMore | ||
assert.strictEqual(readable._readableState.readingMore, false); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please require
../common.js
, as done in other test files.