test: added test for nodeId generation

added test for addNode id generation

ref: N25B-114
This commit is contained in:
JGerla
2025-10-25 20:59:41 +02:00
parent 9bfc39afa1
commit 416025bf3f

View File

@@ -17,4 +17,14 @@ describe('Drag-and-Drop sidebar', () => {
expect(updatedState.nodes.length).toBe(1);
expect(updatedState.nodes[0].type).toBe(nodeType);
});
test.each(['phase', 'norm'])('new nodes get correct Id', (nodeType) => {
act(()=> {
addNode(nodeType, {x:100, y:100});
addNode(nodeType, {x:100, y:100});
})
const updatedState = useFlowStore.getState();
expect(updatedState.nodes.length).toBe(2);
expect(updatedState.nodes[0].id).toBe(`${nodeType}-0`);
expect(updatedState.nodes[1].id).toBe(`${nodeType}-1`);
});
});