Files
beacon-web/tests/features/map/useMapBordersData.test.ts
T
MrAlders0n 464e701f76 Add a toggleable IATA border layer to the map
Draw each active IATA's GeoJSON region border as an outline over a faint
fill beneath the node markers, behind a Map Settings toggle that's off by
default and shareable via a URL param. IATAs with no border answer 204
and are skipped.
2026-07-24 22:21:12 -04:00

32 lines
1.2 KiB
TypeScript

import { describe, it, expect } from "vitest";
import { mergeBorders } from "../../../src/features/map/useMapBordersData";
import type { Feature, Polygon } from "geojson";
const poly = (id: number): Feature<Polygon> => ({
type: "Feature",
properties: { name: `p${id}` },
geometry: { type: "Polygon", coordinates: [[[id, 0], [id + 1, 0], [id + 1, 1], [id, 0]]] },
});
describe("mergeBorders", () => {
it("drops IATAs with no border and stamps the iata onto each feature's properties", () => {
const fc = mergeBorders([
{ iata: "YOW", border: poly(0) },
{ iata: "YYZ", border: null },
{ iata: "YUL", border: poly(5) },
]);
expect(fc.type).toBe("FeatureCollection");
expect(fc.features).toHaveLength(2);
expect(fc.features.map((f) => f.properties.iata)).toEqual(["YOW", "YUL"]);
// existing properties and geometry survive the merge
expect(fc.features[0]!.properties.name).toBe("p0");
expect(fc.features[0]!.geometry).toEqual(poly(0).geometry);
});
it("returns an empty FeatureCollection when nothing has a border", () => {
const fc = mergeBorders([{ iata: "YOW", border: null }]);
expect(fc.features).toHaveLength(0);
});
});