Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Use ApolloClient#stop to clean up MockedProvider client. (#2741)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn authored Jan 19, 2019
1 parent 0051af1 commit efac246
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"trailingComma": "all"
},
"peerDependencies": {
"apollo-client": "^2.3.8",
"apollo-client": "^2.4.12",
"react": "^15.0.0 || ^16.0.0",
"react-dom": "^15.0.0 || ^16.0.0",
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
Expand All @@ -111,7 +111,7 @@
"@types/zen-observable": "0.8.0",
"apollo-cache": "^1.1.25",
"apollo-cache-inmemory": "^1.4.2",
"apollo-client": "^2.4.11",
"apollo-client": "^2.4.12",
"apollo-link": "1.2.1",
"babel-core": "6.26.3",
"babel-jest": "23.6.0",
Expand Down
13 changes: 3 additions & 10 deletions src/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,8 @@ export class MockedProvider extends React.Component<MockedProviderProps, MockedP
}

public componentWillUnmount() {
if (!this.state.client.queryManager) {
return;
}
const scheduler = this.state.client.queryManager.scheduler;
Object.keys(scheduler.registeredQueries).forEach(queryId => {
scheduler.stopPollingQuery(queryId);
});
Object.keys(scheduler.intervalQueries).forEach((interval: any) => {
scheduler.fetchQueriesOnInterval(interval);
});
// Since this.state.client was created in the constructor, it's this
// MockedProvider's responsibility to terminate it.
this.state.client.stop();
}
}

0 comments on commit efac246

Please sign in to comment.