Derive device voltages from project settings
This commit is contained in:
@@ -4,6 +4,10 @@ import {
|
||||
calculateCircuitTotalPower,
|
||||
calculateRowTotalPower,
|
||||
} from "../src/domain/calculations/circuit-power-calculation.js";
|
||||
import {
|
||||
resolveCircuitPhaseType,
|
||||
resolveProjectVoltage,
|
||||
} from "../src/domain/services/project-voltage.service.js";
|
||||
|
||||
describe("circuit power calculation", () => {
|
||||
it("calculates row and circuit totals from device rows", () => {
|
||||
@@ -16,3 +20,28 @@ describe("circuit power calculation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("project voltage derivation", () => {
|
||||
const settings = {
|
||||
singlePhaseVoltageV: 240,
|
||||
threePhaseVoltageV: 415,
|
||||
};
|
||||
|
||||
it("derives device voltage exclusively from phase and project settings", () => {
|
||||
assert.equal(resolveProjectVoltage("single_phase", settings), 240);
|
||||
assert.equal(resolveProjectVoltage("three_phase", settings), 415);
|
||||
});
|
||||
|
||||
it("uses section phase and handles unassigned circuits conservatively", () => {
|
||||
assert.equal(resolveCircuitPhaseType("lighting", ["three_phase"]), "single_phase");
|
||||
assert.equal(resolveCircuitPhaseType("single_phase", ["three_phase"]), "single_phase");
|
||||
assert.equal(resolveCircuitPhaseType("three_phase", ["single_phase"]), "three_phase");
|
||||
assert.equal(resolveCircuitPhaseType("unassigned", ["three_phase"]), "three_phase");
|
||||
assert.equal(
|
||||
resolveCircuitPhaseType("unassigned", ["three_phase", "single_phase"]),
|
||||
"single_phase"
|
||||
);
|
||||
assert.equal(resolveCircuitPhaseType("unassigned", []), "single_phase");
|
||||
assert.equal(resolveCircuitPhaseType("unassigned", [null]), "single_phase");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user