Add atomic device row updates
This commit is contained in:
@@ -9,6 +9,10 @@ import {
|
||||
assertCircuitUpdateProjectCommand,
|
||||
createCircuitUpdateProjectCommand,
|
||||
} from "../src/domain/models/circuit-project-command.model.js";
|
||||
import {
|
||||
assertCircuitDeviceRowUpdateProjectCommand,
|
||||
createCircuitDeviceRowUpdateProjectCommand,
|
||||
} from "../src/domain/models/circuit-device-row-project-command.model.js";
|
||||
|
||||
describe("serialized project commands", () => {
|
||||
it("round-trips a versioned command envelope", () => {
|
||||
@@ -122,3 +126,43 @@ describe("circuit update project commands", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("circuit device-row update project commands", () => {
|
||||
it("creates typed nullable device-row changes", () => {
|
||||
const command = createCircuitDeviceRowUpdateProjectCommand("row-1", {
|
||||
roomId: null,
|
||||
quantity: 2,
|
||||
cosPhi: 0.9,
|
||||
});
|
||||
|
||||
assert.doesNotThrow(() =>
|
||||
assertCircuitDeviceRowUpdateProjectCommand(command)
|
||||
);
|
||||
assert.deepEqual(command.payload.changes, [
|
||||
{ field: "roomId", value: null },
|
||||
{ field: "quantity", value: 2 },
|
||||
{ field: "cosPhi", value: 0.9 },
|
||||
]);
|
||||
});
|
||||
|
||||
it("rejects invalid device-row values", () => {
|
||||
assert.throws(
|
||||
() => createCircuitDeviceRowUpdateProjectCommand("row-1", {}),
|
||||
/at least one change/
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
createCircuitDeviceRowUpdateProjectCommand("row-1", {
|
||||
displayName: "",
|
||||
}),
|
||||
/non-empty string/
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
createCircuitDeviceRowUpdateProjectCommand("row-1", {
|
||||
quantity: -1,
|
||||
}),
|
||||
/non-negative/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user