-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add peek
to ObservableStream
and use ObservableStream
in an existing test
#12307
Conversation
|
✅ Docs preview has no changesThe preview was not built because there were no changes. Build ID: 8bf57c32c3b676722dcd8c13 |
commit: |
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
size-limit report 📦
|
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.
Many of these tests were hard to reason about because it was difficult to tell that some of the assertions were there to ensure that the observable didn't emit any new values (which is why it looked like some values were tested multiple times).
Moving this to ObservableStream
makes it much easier to read through the expected changes. This will be useful in #12304 which will better show off the changes to the values made in that branch.
This change introduces two things:
peek
function toObservableStream
that lets you peek at the next value "without" consuming the next reader eventThe
peek
function was necessary due to how these tests operate. Several areas of the refactored test did something like the following:Because
toEmitAnything
consumed a reader event, that meant usingawait expect(bStream).toEmitValue(...)
wouldn't quite work as you'd expect since it would be reporting the value after the event consumed by the previousnot.toEmitAnything()
. Rather than omitting this check entirely, I added apeek
function that will consume the reader event, then queue it so thattake
will take from the peeked event rather than advancing the reader. This allowed me to updatetoEmitAnything
to usepeek
instead so that I could continue to usetoEmitValue
further down.