Files
next-tjwater-drainage-frontend/features/workbench/map/map-control-config.test.ts
T

55 lines
1.5 KiB
TypeScript

import type { Map as MapLibreMap } from "maplibre-gl";
import { describe, expect, it } from "vitest";
import { waterNetworkLayers } from "./layers";
import {
INITIAL_LAYER_VISIBILITY,
createLayerControlItems,
getWorkbenchLayerIds
} from "./map-control-config";
describe("workbench source layer controls", () => {
it("creates one business control for each Lingang source", () => {
const items = createLayerControlItems(INITIAL_LAYER_VISIBILITY);
expect(items.map((item) => item.id)).toEqual([
"conduits",
"junctions",
"orifices",
"outfalls",
"pumps"
]);
expect(items.slice(0, 5).map((item) => item.description)).toEqual([
"lingang:geo_conduits_mat",
"lingang:geo_junctions_mat",
"lingang:geo_orifices_mat",
"lingang:geo_outfalls_mat",
"lingang:geo_pumps_mat"
]);
});
it("finds every rendered layer that uses a source", () => {
const map = {
getStyle: () => ({ version: 8, sources: {}, layers: waterNetworkLayers })
} as Pick<MapLibreMap, "getStyle">;
expect(getWorkbenchLayerIds(map, "orifices")).toEqual([
"orifices-casing",
"orifices",
"orifices-hover-outline",
"orifices-hover",
"orifices-selected-halo",
"orifices-selected-outline",
"orifices-selected",
"orifices-hit"
]);
expect(getWorkbenchLayerIds(map, "outfalls")).toEqual([
"outfalls-halo",
"outfalls",
"outfalls-hover",
"outfalls-selected-halo",
"outfalls-selected",
"outfalls-hit"
]);
});
});