import type { LngLat, LngLatBounds, LngLatLike, MapMouseEvent } from "mapbox-gl"; /** * Type for event handlers stored in our mock map's listener registry. * Using a generic to avoid `as` assertions when retrieving handlers. */ type MapEventHandler = (event: TEvent) => void; /** * Shape of the mock map returned by createMockMapboxMap. * Extends the necessary parts of mapboxgl.Map for adapter testing. */ type MockMapboxMap = { on: jest.Mock; once: jest.Mock; off: jest.Mock; remove: jest.Mock; getCenter: jest.Mock; getZoom: jest.Mock; getBounds: jest.Mock; setCenter: jest.Mock; setZoom: jest.Mock; panTo: jest.Mock; panBy: jest.Mock; fitBounds: jest.Mock; setStyle: jest.Mock; isStyleLoaded: jest.Mock; isMoving: jest.Mock; addSource: jest.Mock; removeSource: jest.Mock; getSource: jest.Mock; addLayer: jest.Mock; removeLayer: jest.Mock; getLayer: jest.Mock; setPaintProperty: jest.Mock; hasImage: jest.Mock; addImage: jest.Mock; getCanvas: jest.Mock; getCanvasContainer: jest.Mock; }; /** * Return type of createMockMapboxMap - provides both the mock map * and a triggerEvent helper for simulating Mapbox events in tests. */ type MockMapboxMapResult = { /** * The mock map instance. Cast to mapboxgl.Map when passing to adapter.connect(). * We return MockMapboxMap to preserve access to jest mock methods in tests. */ readonly map: MockMapboxMap; /** * Triggers an event on the mock map, calling all registered handlers. * Handles both regular (on) and one-time (once) listeners. */ readonly triggerEvent: (eventName: string, event?: TEvent) => void; }; /** * Creates a mock Mapbox map instance for unit testing adapter instances directly. * * Use this when you need fine-grained control over mock behavior, such as: * - Testing adapter instance methods (connect, setCenter, etc.) * - Simulating map events (idle, click, movestart) * - Verifying method calls on the map * * @example * ```typescript * import { createMockMapboxMap } from "@trackunit/react-test-setup"; * * it("should connect to map", () => { * const { map, triggerEvent } = createMockMapboxMap(); * const adapter = new MapboxAdapterInstance(config); * * adapter.connect(map as unknown as mapboxgl.Map); * triggerEvent("idle"); * * expect(adapter.getState().isReady).toBe(true); * }); * ``` */ export declare const createMockMapboxMap: () => MockMapboxMapResult; /** * Mock click event matching Mapbox GL's MapMouseEvent shape. * Use with triggerEvent("click", createMockClickEvent(...)) * * Note: The `point` property is intentionally omitted because: * 1. It requires the full Point class from @mapbox/point-geometry with 30+ methods * 2. No tests currently use the point property * 3. Since this returns Partial, point is optional */ export declare const createMockClickEvent: (lng: number, lat: number) => Partial; /** * Sets up mocks for Mapbox GL JS in testing environments. * * This function mocks the mapbox-gl module with functional mock implementations, * allowing tests of map-dependent components to run without WebGL or actual * network requests. * * Key features: * - Mocks mapboxgl.Map constructor to return a trackable mock instance * - Auto-fires the "load" event after map construction (for renderer tests) * - Provides mock implementations for all common map methods * - Resets mock state between tests via beforeEach * * @example * ```typescript * // In your test file * import { setupMapbox } from "@trackunit/react-test-setup"; * * setupMapbox(); * * describe("MapboxRenderer", () => { * it("renders map when loaded", async () => { * // The mock will auto-fire "load" event * render(); * await waitFor(() => expect(screen.getByRole("application")).toBeInTheDocument()); * }); * }); * ``` */ export declare const setupMapbox: () => void; export {};