Add device row history commands
This commit is contained in:
@@ -13,6 +13,11 @@ import {
|
||||
assertCircuitDeviceRowUpdateProjectCommand,
|
||||
createCircuitDeviceRowUpdateProjectCommand,
|
||||
} from "../src/domain/models/circuit-device-row-project-command.model.js";
|
||||
import {
|
||||
assertCircuitDeviceRowInsertProjectCommand,
|
||||
createCircuitDeviceRowDeleteProjectCommand,
|
||||
createCircuitDeviceRowInsertProjectCommand,
|
||||
} from "../src/domain/models/circuit-device-row-structure-project-command.model.js";
|
||||
|
||||
describe("serialized project commands", () => {
|
||||
it("round-trips a versioned command envelope", () => {
|
||||
@@ -166,3 +171,72 @@ describe("circuit device-row update project commands", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("circuit device-row structure project commands", () => {
|
||||
const row = {
|
||||
id: "row-1",
|
||||
circuitId: "circuit-1",
|
||||
linkedProjectDeviceId: null,
|
||||
legacyConsumerId: null,
|
||||
sortOrder: 10,
|
||||
name: "Leuchte",
|
||||
displayName: "Leuchte",
|
||||
phaseType: "single_phase",
|
||||
connectionKind: null,
|
||||
costGroup: null,
|
||||
category: "lighting",
|
||||
level: null,
|
||||
roomId: null,
|
||||
roomNumberSnapshot: null,
|
||||
roomNameSnapshot: null,
|
||||
quantity: 1,
|
||||
powerPerUnit: 0.1,
|
||||
simultaneityFactor: 1,
|
||||
cosPhi: 0.9,
|
||||
remark: null,
|
||||
overriddenFields: null,
|
||||
};
|
||||
|
||||
it("captures complete insert and delete identities", () => {
|
||||
const insert = createCircuitDeviceRowInsertProjectCommand(row);
|
||||
const remove = createCircuitDeviceRowDeleteProjectCommand(
|
||||
row.id,
|
||||
row.circuitId
|
||||
);
|
||||
|
||||
assert.deepEqual(insert.payload.row, row);
|
||||
assert.deepEqual(remove.payload, {
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: "circuit-1",
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects incomplete snapshots and invalid values", () => {
|
||||
assert.throws(
|
||||
() =>
|
||||
assertCircuitDeviceRowInsertProjectCommand({
|
||||
schemaVersion: 1,
|
||||
type: "circuit-device-row.insert",
|
||||
payload: {
|
||||
row: {
|
||||
...row,
|
||||
linkedProjectDeviceId: undefined,
|
||||
},
|
||||
},
|
||||
}),
|
||||
/linkedProjectDeviceId/
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
createCircuitDeviceRowInsertProjectCommand({
|
||||
...row,
|
||||
quantity: -1,
|
||||
}),
|
||||
/must not be negative/
|
||||
);
|
||||
assert.throws(
|
||||
() => createCircuitDeviceRowDeleteProjectCommand("", "circuit-1"),
|
||||
/rowId/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user