Files
leistungsbilanz-ts/tests/project-device-placement.service.test.ts

39 lines
1.3 KiB
TypeScript

import assert from "node:assert/strict";
import { describe, it } from "node:test";
import {
inferProjectDeviceSectionKey,
isProjectDevicePlacementValid,
} from "../src/domain/services/project-device-placement.service.js";
describe("project device placement", () => {
it("routes lighting categories to the lighting section before phase classification", () => {
assert.equal(
inferProjectDeviceSectionKey({ category: "Lighting", phaseType: "three_phase" }),
"lighting"
);
assert.equal(
inferProjectDeviceSectionKey({ category: "Beleuchtung", phaseType: "single_phase" }),
"lighting"
);
});
it("routes non-lighting devices by phase type", () => {
assert.equal(
inferProjectDeviceSectionKey({ category: "Socket", phaseType: "single_phase" }),
"single_phase"
);
assert.equal(
inferProjectDeviceSectionKey({ category: "Motor", phaseType: "three_phase" }),
"three_phase"
);
});
it("accepts only the inferred default section", () => {
const device = { category: "Motor", phaseType: "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);
});
});