56 lines
1.6 KiB
TypeScript
56 lines
1.6 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",
|
|
"scada"
|
|
]);
|
|
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-outer",
|
|
"orifices-selected-outline",
|
|
"orifices-selected-separator",
|
|
"orifices-hit"
|
|
]);
|
|
expect(getWorkbenchLayerIds(map, "outfalls")).toEqual([
|
|
"outfalls-halo",
|
|
"outfalls",
|
|
"outfalls-hover",
|
|
"outfalls-selected-outer",
|
|
"outfalls-selected",
|
|
"outfalls-hit"
|
|
]);
|
|
});
|
|
});
|