forked from jappel/leistungsbilanz-ts
Phase 1A done
This commit is contained in:
parent
49190c5d7e
commit
b8995b3a1b
21 changed files with 1038 additions and 3 deletions
57
tests/legacy-consumer-migration-planner.test.ts
Normal file
57
tests/legacy-consumer-migration-planner.test.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import assert from "node:assert/strict";
|
||||
import { describe, it } from "node:test";
|
||||
import {
|
||||
inferSectionKeyFromEquipmentIdentifier,
|
||||
inferSectionKeyFromLegacyInput,
|
||||
normalizeCircuitNumber,
|
||||
} from "../src/domain/services/legacy-consumer-migration-planner.js";
|
||||
|
||||
describe("legacy consumer migration planner", () => {
|
||||
it("normalizes valid circuit numbers and rejects invalid formats", () => {
|
||||
assert.equal(normalizeCircuitNumber(" -2f12 "), "-2F12");
|
||||
assert.equal(normalizeCircuitNumber("2F12"), null);
|
||||
assert.equal(normalizeCircuitNumber(""), null);
|
||||
assert.equal(normalizeCircuitNumber(null), null);
|
||||
});
|
||||
|
||||
it("infers section from equipment identifier prefix", () => {
|
||||
assert.equal(inferSectionKeyFromEquipmentIdentifier("-1F4"), "lighting");
|
||||
assert.equal(inferSectionKeyFromEquipmentIdentifier("-2F8"), "single_phase");
|
||||
assert.equal(inferSectionKeyFromEquipmentIdentifier("-3F1"), "three_phase");
|
||||
assert.equal(inferSectionKeyFromEquipmentIdentifier("-9F1"), null);
|
||||
});
|
||||
|
||||
it("infers section from category/phase when circuit number is missing", () => {
|
||||
assert.equal(
|
||||
inferSectionKeyFromLegacyInput({
|
||||
id: "1",
|
||||
circuitNumber: null,
|
||||
category: "Beleuchtung",
|
||||
phaseType: null,
|
||||
phaseCount: null,
|
||||
}),
|
||||
"lighting"
|
||||
);
|
||||
assert.equal(
|
||||
inferSectionKeyFromLegacyInput({
|
||||
id: "2",
|
||||
circuitNumber: null,
|
||||
category: null,
|
||||
phaseType: "three-phase",
|
||||
phaseCount: null,
|
||||
}),
|
||||
"three_phase"
|
||||
);
|
||||
assert.equal(
|
||||
inferSectionKeyFromLegacyInput({
|
||||
id: "3",
|
||||
circuitNumber: null,
|
||||
category: null,
|
||||
phaseType: null,
|
||||
phaseCount: null,
|
||||
}),
|
||||
null
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue