forked from jappel/leistungsbilanz-ts
Validate project device drop targets
This commit is contained in:
parent
b2f5ce77a5
commit
fd62bf2e15
6 changed files with 231 additions and 30 deletions
38
tests/project-device-placement.service.test.ts
Normal file
38
tests/project-device-placement.service.test.ts
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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);
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue