Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

test(map): the phone hook mock keeps the number of hooks stable

Maurice322d5d520977
diff --git a/client/src/components/Map/MapView.test.tsx b/client/src/components/Map/MapView.test.tsx
index b4496cef8..aa4200bb9 100644
--- a/client/src/components/Map/MapView.test.tsx
+++ b/client/src/components/Map/MapView.test.tsx
@@ -211,7 +211,15 @@ vi.mock('../../services/photoService', () => ({
const shell = vi.hoisted(() => ({ phone: undefined as boolean | undefined }))
vi.mock('../../mobile/useIsPhone', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../mobile/useIsPhone')>()
- return { ...actual, useIsPhone: () => shell.phone ?? actual.useIsPhone() }
+ // The real hook runs every time, so a test that changes the answer never changes the
+ // number of hooks a mounted map has (React throws on that).
+ return {
+ ...actual,
+ useIsPhone: () => {
+ const real = actual.useIsPhone()
+ return shell.phone ?? real
+ },
+ }
})
vi.mock('./gcj02Crs', () => ({