mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-09-02 17:23:45 +00:00
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.
32 lines
1.2 KiB
TypeScript
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);
|
|
});
|
|
});
|