Standardize phase type labels
This commit is contained in:
@@ -82,6 +82,8 @@ describe("circuit grid model", () => {
|
||||
assert.equal(formatValue(0.87654, "simultaneityFactor"), "0,88");
|
||||
assert.equal(formatValue(230.4, "voltage"), "230");
|
||||
assert.equal(formatValue(16, "protectionRatedCurrent"), "16");
|
||||
assert.equal(formatValue("single_phase", "phaseType"), "1-phasig");
|
||||
assert.equal(formatValue("three_phase", "phaseType"), "3-phasig");
|
||||
});
|
||||
|
||||
it("uses circuit display values for block sorting and falls back to the first device", () => {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
import {
|
||||
resolveCircuitPhaseType,
|
||||
resolveProjectVoltage,
|
||||
normalizeKnownElectricalPhaseType,
|
||||
} from "../src/domain/services/project-voltage.service.js";
|
||||
|
||||
describe("circuit power calculation", () => {
|
||||
@@ -43,5 +44,17 @@ describe("project voltage derivation", () => {
|
||||
assert.equal(resolveCircuitPhaseType("unassigned", []), "single_phase");
|
||||
assert.equal(resolveCircuitPhaseType("unassigned", [null]), "single_phase");
|
||||
});
|
||||
|
||||
it("normalizes known legacy phase labels without guessing unknown values", () => {
|
||||
assert.equal(normalizeKnownElectricalPhaseType("1phasig"), "single_phase");
|
||||
assert.equal(normalizeKnownElectricalPhaseType("1-phasig"), "single_phase");
|
||||
assert.equal(normalizeKnownElectricalPhaseType("3phase"), "three_phase");
|
||||
assert.equal(normalizeKnownElectricalPhaseType("3-phasig"), "three_phase");
|
||||
assert.equal(normalizeKnownElectricalPhaseType(null), null);
|
||||
assert.throws(
|
||||
() => normalizeKnownElectricalPhaseType("zweiphasig"),
|
||||
/Unknown electrical phase type/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user