Merging dev into main #49
@@ -13,11 +13,6 @@ import useFlowStore from "../VisProgStores.tsx";
|
||||
import styles from "../../VisProg.module.css"
|
||||
|
||||
|
||||
// Is used to make sure each subsequent node gets a unique id, so the ReactFlow implementation
|
||||
// can distinguish between different nodes.
|
||||
let id = 0;
|
||||
const getId = () => `dndnode_${id++}`;
|
||||
|
||||
/**
|
||||
* DraggableNodeProps dictates the type properties of a DraggableNode
|
||||
*/
|
||||
@@ -97,12 +92,7 @@ export function addNode(nodeType: string, position: XYPosition) {
|
||||
};
|
||||
}
|
||||
default: {
|
||||
return {
|
||||
id: getId(),
|
||||
type: nodeType,
|
||||
position,
|
||||
data: {label: `new default node`},
|
||||
};
|
||||
throw new Error(`Node ${nodeType} not found`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,7 @@ describe('Drag-and-Drop sidebar', () => {
|
||||
expect(updatedState.nodes[0].id).toBe(`${nodeType}-0`);
|
||||
expect(updatedState.nodes[1].id).toBe(`${nodeType}-1`);
|
||||
});
|
||||
test('throws error on unexpected node type', () => {
|
||||
expect(() => addNode('I do not Exist', {x:100, y:100})).toThrow("Node I do not Exist not found");
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user