diff --git a/src/components/map/map-view.test.tsx b/src/components/map/map-view.test.tsx index df29991..d081f5d 100644 --- a/src/components/map/map-view.test.tsx +++ b/src/components/map/map-view.test.tsx @@ -3,6 +3,35 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import MapView from "@/components/map/map-view"; +vi.mock("react-leaflet", async () => { + const React = await import("react"); + const map = { + getBounds: () => ({ + getWest: () => -1, + getSouth: () => -1, + getEast: () => 1, + getNorth: () => 1, + }), + getZoom: () => 18, + getContainer: () => document.createElement("div"), + fitBounds: vi.fn(), + scrollWheelZoom: { disable: vi.fn(), enable: vi.fn(), enabled: () => false }, + on: vi.fn(), + off: vi.fn(), + }; + return { + MapContainer: ({ children }: React.PropsWithChildren) =>
{children}
, + Marker: ({ title }: React.PropsWithChildren<{ title?: string }>) => ( +
+ ), + Popup: ({ children }: React.PropsWithChildren) =>
{children}
, + TileLayer: () => null, + Tooltip: () => null, + CircleMarker: () => null, + useMap: () => map, + }; +}); + afterEach(() => { cleanup(); vi.unstubAllEnvs(); @@ -28,4 +57,35 @@ describe("MapView configuration", () => { expect.stringContaining("NEXT_PUBLIC_MAPTILER_KEY is missing"), ); }); + + it("gives a single place pin an accessible name with its category", () => { + vi.stubEnv("NEXT_PUBLIC_MAPTILER_KEY", "test-key"); + vi.stubGlobal( + "ResizeObserver", + class { + observe() {} + disconnect() {} + }, + ); + render( + , + ); + + expect( + screen.getByRole("button", { name: /Heathrow Airport, Airport/ }), + ).toBeTruthy(); + }); }); diff --git a/src/components/map/map-view.tsx b/src/components/map/map-view.tsx index 9cfd3c3..63385d6 100644 --- a/src/components/map/map-view.tsx +++ b/src/components/map/map-view.tsx @@ -175,6 +175,7 @@ function ClusteredMarkers({ places }: { places: Place[] }) { {