From ab35447c129f4e0b02e3cf2b10f6a98b2b3e0a9d Mon Sep 17 00:00:00 2001 From: Max Kohler Date: Wed, 23 Jul 2025 10:44:09 +0200 Subject: [PATCH 1/3] Block out bindable mapContext --- .../src/maplibre/Map/Map.stories.svelte | 62 ++++++++++++++++++- components/src/maplibre/Map/Map.svelte | 28 +++++++-- .../src/maplibre/MapStyle/SWRDataLabLight.mdx | 2 +- components/src/maplibre/Maplibre.mdx | 2 + 4 files changed, 87 insertions(+), 7 deletions(-) diff --git a/components/src/maplibre/Map/Map.stories.svelte b/components/src/maplibre/Map/Map.stories.svelte index 12be5e7d..a4e90850 100644 --- a/components/src/maplibre/Map/Map.stories.svelte +++ b/components/src/maplibre/Map/Map.stories.svelte @@ -1,6 +1,6 @@ - + { + const canvas = within(canvasElement); + const containerEl = canvas.getByTestId('map-container'); + const flyToBerlinButton = canvas.getByTestId('flyto-berlin'); + + await step('map renders', async () => { + const mapEl = containerEl.querySelector('.maplibregl-canvas'); + expect(mapEl).toBeTruthy(); + }); + await step('mapContext prop receives valid data', async () => { + expect(mapContext).toBeInstanceOf(MapContext); + }); + await step('external trigger map events', async () => { + await userEvent.click(flyToBerlinButton); + expect(onMoveStart).toHaveBeenCalled(); + // We'd like to expext.poll() for onMoveEnd.toHaveBeenCalled() + // here but that API doesn't exist in Storybook, see: + // https://github.com/storybookjs/storybook/issues/29060 + }); + }} +> +
+ + + + + + + + + +
+
+
diff --git a/components/src/maplibre/Map/Map.svelte b/components/src/maplibre/Map/Map.svelte index d5c1389c..4f0350b0 100644 --- a/components/src/maplibre/Map/Map.svelte +++ b/components/src/maplibre/Map/Map.svelte @@ -1,7 +1,11 @@