diff --git a/test/pages/visProgPage/visualProgrammingUI/VisProgStores.test.tsx b/test/pages/visProgPage/visualProgrammingUI/VisProgStores.test.tsx index a9ae892..be59640 100644 --- a/test/pages/visProgPage/visualProgrammingUI/VisProgStores.test.tsx +++ b/test/pages/visProgPage/visualProgrammingUI/VisProgStores.test.tsx @@ -20,6 +20,7 @@ describe('FlowStore Functionality', () => { describe('ReactFlow onConnect', () => { test('adds an edge when onConnect is triggered', () => { const {onConnect} = useFlowStore.getState(); + act(() => { onConnect({ source: 'A', @@ -38,6 +39,34 @@ describe('FlowStore Functionality', () => { }); }); describe('ReactFlow onReconnect', () => { + test('reconnects an existing edge when onReconnect is triggered', () => { + const {onReconnect} = useFlowStore.getState(); + const oldEdge = { + id: 'xy-edge__A-B', + source: 'A', + target: 'B' + }; + const newConnection = { + source: 'A', + target: 'C', + sourceHandle: null, + targetHandle: null, + }; + act(() => { + useFlowStore.setState({ + edges: [oldEdge] + }); + onReconnect(oldEdge, newConnection); + }); + + const updatedEdges = useFlowStore.getState().edges; + expect(updatedEdges).toHaveLength(1); + expect(updatedEdges[0]).toMatchObject({ + id: 'xy-edge__A-C', + source: 'A', + target: 'C', + }); + }); }); describe('ReactFlow onReconnectStart', () => { });