Merging dev into main #49
@@ -125,6 +125,42 @@ describe('FlowStore Functionality', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
describe('ReactFlow deleteNode', () => {
|
||||
// test deleting A and B, so we make sure the connecting edge gets deleted regardless of
|
||||
test.each([['A','B'],['B','A']])('deletes a node and its connected edges', (nodeId, undeletedNodeId) => {
|
||||
const {deleteNode} = useFlowStore.getState();
|
||||
useFlowStore.setState({
|
||||
nodes: [
|
||||
{
|
||||
id: 'A',
|
||||
type: 'default',
|
||||
position: {x: 0, y: 0},
|
||||
data: {label: 'A'}
|
||||
},
|
||||
{
|
||||
id: 'B',
|
||||
type: 'default',
|
||||
position: {x: 0, y: 300},
|
||||
data: {label: 'A'}
|
||||
}],
|
||||
edges: [
|
||||
{
|
||||
id: 'xy-edge__A-B',
|
||||
source: 'A',
|
||||
target: 'B'
|
||||
}]
|
||||
});
|
||||
|
||||
act(()=> {
|
||||
deleteNode(nodeId);
|
||||
});
|
||||
|
||||
const updatedState = useFlowStore.getState();
|
||||
expect(updatedState.edges).toHaveLength(0);
|
||||
expect(updatedState.nodes).toHaveLength(1);
|
||||
expect(updatedState.nodes[0].id).toBe(undeletedNodeId);
|
||||
});
|
||||
});
|
||||
describe('ReactFlow setNodes', () => {
|
||||
test('sets nodes to the provided list of nodes', () => {
|
||||
const {setNodes} = useFlowStore.getState();
|
||||
|
||||
Reference in New Issue
Block a user