test: added tests for onReconnectEnd

ref: N25B-114
This commit is contained in:
JGerla
2025-10-25 16:03:57 +02:00
parent 48dabb86e0
commit c8484d28e5

View File

@@ -81,6 +81,49 @@ describe('FlowStore Functionality', () => {
});
});
describe('ReactFlow onReconnectEnd', () => {
// prepares the state to have an edge in the edge array
beforeEach(() => {
useFlowStore.setState({edges: [
{
id: 'xy-edge__A-B',
source: 'A',
target: 'B'
}
]}
);
});
test('successfully removes edge if no successful reconnect occurred', () => {
const {onReconnectEnd} = useFlowStore.getState();
useFlowStore.setState({edgeReconnectSuccessful: false});
act(() => {
onReconnectEnd(null, {id: 'xy-edge__A-B'});
});
const updatedState = useFlowStore.getState();
expect(updatedState.edgeReconnectSuccessful).toBe(true);
expect(updatedState.edges).toHaveLength(0);
});
test('does not remove reconnecting edge if successful reconnect occurred', () => {
const {onReconnectEnd} = useFlowStore.getState();
act(() => {
onReconnectEnd(null, {id: 'xy-edge__A-B'});
});
const updatedState = useFlowStore.getState();
expect(updatedState.edgeReconnectSuccessful).toBe(true);
expect(updatedState.edges).toHaveLength(1);
expect(updatedState.edges).toMatchObject([
{
id: 'xy-edge__A-B',
source: 'A',
target: 'B'
}]
);
});
});
describe('ReactFlow setNodes', () => {
test('sets nodes to the provided list of nodes', () => {