Files
next-tjwater-drainage-frontend/features/workbench/map/layer-group-style.test.ts
T

19 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { validateLayerGroupStylePatch } from "./layer-group-style";
describe("layer group style validation", () => {
it("accepts geometry-aware style patches", () => {
expect(validateLayerGroupStylePatch("conduits", { color: "#0F766E", opacity: 0.5, widthMultiplier: 3, dash: "solid" })).toBe(true);
expect(validateLayerGroupStylePatch("junctions", { fillColor: "#0369A1", strokeColor: "#FFFFFF", radiusMultiplier: 0.5 })).toBe(true);
expect(validateLayerGroupStylePatch("scada", { iconMultiplier: 2, opacity: 1 })).toBe(true);
});
it("rejects cross-geometry fields and out-of-range values", () => {
expect(validateLayerGroupStylePatch("conduits", { radiusMultiplier: 1 })).toBe(false);
expect(validateLayerGroupStylePatch("junctions", { widthMultiplier: 1 })).toBe(false);
expect(validateLayerGroupStylePatch("scada", { iconMultiplier: 2.1 })).toBe(false);
expect(validateLayerGroupStylePatch("conduits", { color: "red" })).toBe(false);
expect(validateLayerGroupStylePatch("unknown", {})).toBe(false);
});
});