Skip to content

chore: add function to refetch latencies to ProxyContext #7769

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

Merged
merged 6 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix mocks
  • Loading branch information
Emyrk committed Jun 1, 2023
commit ed4aebf6a231f9f4bc8ae7831fdc5b146bddc9d8
4 changes: 2 additions & 2 deletions site/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jest.mock("contexts/useProxyLatency", () => ({
useProxyLatency: (proxies?: RegionsResponse) => {
// Must use `useMemo` here to avoid infinite loop.
// Mocking the hook with a hook.
const latencies = useMemo(() => {
const proxyLatencies = useMemo(() => {
if (!proxies) {
return {} as Record<string, ProxyLatencyReport>
}
Expand All @@ -35,7 +35,7 @@ jest.mock("contexts/useProxyLatency", () => ({
}, {} as Record<string, ProxyLatencyReport>)
}, [proxies])

return latencies
return {proxyLatencies, refetch: jest.fn() }
},
}))

Expand Down
2 changes: 1 addition & 1 deletion site/src/contexts/ProxyContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import userEvent from "@testing-library/user-event"
// here and not inside a unit test.
jest.mock("contexts/useProxyLatency", () => ({
useProxyLatency: () => {
return hardCodedLatencies
return { proxyLatencies: hardCodedLatencies, refetch: jest.fn() }
},
}))

Expand Down