import assert from "node:assert/strict"; import { describe, it } from "node:test"; import { inferProjectDeviceSectionKey, isProjectDevicePlacementValid, resolveProjectDevicePhaseType, } from "../src/domain/services/project-device-placement.service.js"; describe("project device placement", () => { it("routes project devices by their required category", () => { assert.equal(inferProjectDeviceSectionKey({ category: "lighting" }), "lighting"); assert.equal(inferProjectDeviceSectionKey({ category: "single_phase" }), "single_phase"); assert.equal(inferProjectDeviceSectionKey({ category: "three_phase" }), "three_phase"); }); it("accepts only the inferred default section", () => { const device = { category: "three_phase" as const }; assert.equal(isProjectDevicePlacementValid(device, { key: "three_phase" }), true); assert.equal(isProjectDevicePlacementValid(device, { key: "single_phase" }), false); assert.equal(isProjectDevicePlacementValid(device, { key: "unassigned" }), false); }); it("derives the electrical phase type from the category", () => { assert.equal(resolveProjectDevicePhaseType("lighting"), "single_phase"); assert.equal(resolveProjectDevicePhaseType("single_phase"), "single_phase"); assert.equal(resolveProjectDevicePhaseType("three_phase"), "three_phase"); }); });