diff --git a/src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx b/src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx index 8317518..383f72c 100644 --- a/src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx +++ b/src/pages/VisProgPage/visualProgrammingUI/components/DragDropSidebar.tsx @@ -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`); } } } diff --git a/test/pages/visProgPage/visualProgrammingUI/components/DragDropSidebar.test.tsx b/test/pages/visProgPage/visualProgrammingUI/components/DragDropSidebar.test.tsx index c1f9979..ae9b88c 100644 --- a/test/pages/visProgPage/visualProgrammingUI/components/DragDropSidebar.test.tsx +++ b/test/pages/visProgPage/visualProgrammingUI/components/DragDropSidebar.test.tsx @@ -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"); + }) }); \ No newline at end of file