36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import type { MapGeoJSONFeature } from "maplibre-gl";
|
|
import { describe, expect, it } from "vitest";
|
|
import { getWaterNetworkSourceId, toDetailFeature } from "./feature-adapter";
|
|
|
|
describe("feature adapter", () => {
|
|
it("classifies API-backed SCADA features by their canonical source id", () => {
|
|
const feature = {
|
|
id: "SCADA-1",
|
|
source: "scada",
|
|
properties: {
|
|
device_id: "SCADA-1",
|
|
device_type: "pressure",
|
|
node_id: "J-1"
|
|
}
|
|
} as unknown as MapGeoJSONFeature;
|
|
|
|
expect(getWaterNetworkSourceId(feature)).toBe("scada");
|
|
expect(toDetailFeature(feature)).toMatchObject({
|
|
id: "SCADA-1",
|
|
layer: "scada",
|
|
title: "SCADA SCADA-1"
|
|
});
|
|
});
|
|
|
|
it("continues to classify vector features by source layer", () => {
|
|
const feature = {
|
|
id: "J-1",
|
|
source: "water-network",
|
|
sourceLayer: "junctions",
|
|
properties: { id: "J-1" }
|
|
} as unknown as MapGeoJSONFeature;
|
|
|
|
expect(getWaterNetworkSourceId(feature)).toBe("junctions");
|
|
});
|
|
});
|