This repository was archived by the owner on Apr 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 787
Clear out scheduler on MockedProvider unmount #2151
Merged
Merged
+35
−13
Conversation
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
rosskevin
suggested changes
Jul 3, 2018
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.
Looks good, I was going to add better types but wanted to check PRs first. Thanks! If you address the name really quick I think this is good to merge.
src/test-utils.tsx
Outdated
export * from './test-links'; | ||
|
||
export class MockedProvider extends React.Component<any, any> { | ||
static defaultProps = { | ||
interface IProps { |
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.
Prefer export interface MockedProviderProps
- both for reuse/composition and better IDE suggestions
src/test-utils.tsx
Outdated
defaultOptions?: DefaultOptions; | ||
} | ||
|
||
interface IState { |
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.
Prefer export interface MockedProviderState
- consistency with above.
rosskevin
approved these changes
Jul 3, 2018
@rosskevin amended, tests are passing |
danilobuerger
added a commit
to danilobuerger/react-apollo
that referenced
this pull request
Aug 2, 2018
Added Changelog for: * apollographql#2151 * apollographql#2165
hwillson
pushed a commit
that referenced
this pull request
Aug 17, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently using
pollInterval
leads to the following jest error message while testing:This is because when
stopPolling
is called, the actual polling timer is not getting deleted right away but after the interval completes. So we have to wait for one whole interval before jest can exist. SeefetchQueriesOnInterval
in the scheduler for the implementation details.This PR assumes that
MockedProvider
is only ever run with the intention that when it is unmounted every client op should also stop.When
MockedProvider
is going to be unmounted, this PR adds the functionality to loop over all existing registered queries in the scheduler and clearing their intervals immediately.