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

Commit efac246

Browse files
authored
Use ApolloClient#stop to clean up MockedProvider client. (#2741)
This method was introduced in [email protected]: apollographql/apollo-client#4336
1 parent 0051af1 commit efac246

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"trailingComma": "all"
9090
},
9191
"peerDependencies": {
92-
"apollo-client": "^2.3.8",
92+
"apollo-client": "^2.4.12",
9393
"react": "^15.0.0 || ^16.0.0",
9494
"react-dom": "^15.0.0 || ^16.0.0",
9595
"graphql": "^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0"
@@ -111,7 +111,7 @@
111111
"@types/zen-observable": "0.8.0",
112112
"apollo-cache": "^1.1.25",
113113
"apollo-cache-inmemory": "^1.4.2",
114-
"apollo-client": "^2.4.11",
114+
"apollo-client": "^2.4.12",
115115
"apollo-link": "1.2.1",
116116
"babel-core": "6.26.3",
117117
"babel-jest": "23.6.0",

src/test-utils.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,8 @@ export class MockedProvider extends React.Component<MockedProviderProps, MockedP
4242
}
4343

4444
public componentWillUnmount() {
45-
if (!this.state.client.queryManager) {
46-
return;
47-
}
48-
const scheduler = this.state.client.queryManager.scheduler;
49-
Object.keys(scheduler.registeredQueries).forEach(queryId => {
50-
scheduler.stopPollingQuery(queryId);
51-
});
52-
Object.keys(scheduler.intervalQueries).forEach((interval: any) => {
53-
scheduler.fetchQueriesOnInterval(interval);
54-
});
45+
// Since this.state.client was created in the constructor, it's this
46+
// MockedProvider's responsibility to terminate it.
47+
this.state.client.stop();
5548
}
5649
}

0 commit comments

Comments
 (0)