Add device row move history
This commit is contained in:
@@ -18,6 +18,10 @@ import {
|
||||
createCircuitDeviceRowDeleteProjectCommand,
|
||||
createCircuitDeviceRowInsertProjectCommand,
|
||||
} from "../src/domain/models/circuit-device-row-structure-project-command.model.js";
|
||||
import {
|
||||
assertCircuitDeviceRowMoveProjectCommand,
|
||||
createCircuitDeviceRowMoveProjectCommand,
|
||||
} from "../src/domain/models/circuit-device-row-move-project-command.model.js";
|
||||
import {
|
||||
assertCircuitInsertProjectCommand,
|
||||
createCircuitDeleteProjectCommand,
|
||||
@@ -246,6 +250,71 @@ describe("circuit device-row structure project commands", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("circuit device-row move project commands", () => {
|
||||
it("captures deterministic source and target positions", () => {
|
||||
const command = createCircuitDeviceRowMoveProjectCommand([
|
||||
{
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: "circuit-1",
|
||||
expectedSortOrder: 10,
|
||||
targetCircuitId: "circuit-2",
|
||||
targetSortOrder: 30,
|
||||
},
|
||||
{
|
||||
rowId: "row-2",
|
||||
expectedCircuitId: "circuit-1",
|
||||
expectedSortOrder: 20,
|
||||
targetCircuitId: "circuit-2",
|
||||
targetSortOrder: 40,
|
||||
},
|
||||
]);
|
||||
assert.equal(command.payload.moves.length, 2);
|
||||
assert.doesNotThrow(() =>
|
||||
assertCircuitDeviceRowMoveProjectCommand(command)
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects empty, duplicate and no-op moves", () => {
|
||||
assert.throws(
|
||||
() => createCircuitDeviceRowMoveProjectCommand([]),
|
||||
/at least one move/
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
createCircuitDeviceRowMoveProjectCommand([
|
||||
{
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: "circuit-1",
|
||||
expectedSortOrder: 10,
|
||||
targetCircuitId: "circuit-2",
|
||||
targetSortOrder: 20,
|
||||
},
|
||||
{
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: "circuit-1",
|
||||
expectedSortOrder: 30,
|
||||
targetCircuitId: "circuit-2",
|
||||
targetSortOrder: 40,
|
||||
},
|
||||
]),
|
||||
/duplicate row ids/
|
||||
);
|
||||
assert.throws(
|
||||
() =>
|
||||
createCircuitDeviceRowMoveProjectCommand([
|
||||
{
|
||||
rowId: "row-1",
|
||||
expectedCircuitId: "circuit-1",
|
||||
expectedSortOrder: 10,
|
||||
targetCircuitId: "circuit-1",
|
||||
targetSortOrder: 10,
|
||||
},
|
||||
]),
|
||||
/no-op/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("circuit structure project commands", () => {
|
||||
const row = {
|
||||
id: "row-1",
|
||||
|
||||
Reference in New Issue
Block a user