From ea79de5ee54ad141967bdb65dde5b329d0862597 Mon Sep 17 00:00:00 2001 From: JGerla Date: Sat, 25 Oct 2025 13:57:37 +0200 Subject: [PATCH] style: restructured and renamed VisProg.test.tsx to VisProgStores.test.tsx renamed as the functionality being tested is contained within the VisProgStores.tsx file and thus the filename for the tests should reflect that relation, so order is preserved in the project. also added a second describe layer to group the tests for all FlowStore functions together for organisational purposes. ref: N25B-114 --- test/pages/visProgPage/VisProg.test.tsx | 30 ------------------ .../VisProgStores.test.tsx | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 30 deletions(-) delete mode 100644 test/pages/visProgPage/VisProg.test.tsx create mode 100644 test/pages/visProgPage/visualProgrammingUI/VisProgStores.test.tsx diff --git a/test/pages/visProgPage/VisProg.test.tsx b/test/pages/visProgPage/VisProg.test.tsx deleted file mode 100644 index 96cb342..0000000 --- a/test/pages/visProgPage/VisProg.test.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { act } from '@testing-library/react'; -import useFlowStore from '../../../src/pages/VisProgPage/visualProgrammingUI/VisProgStores.tsx'; -import { mockReactFlow } from '../../setupFlowTests.ts'; - -beforeAll(() => { - mockReactFlow(); -}); - -describe('FlowCanvas onConnect', () => { - - test('adds an edge when onConnect is triggered', () => { - const { onConnect} = useFlowStore.getState(); - - act(() => { - onConnect({ - source: 'A', - target: 'B', - sourceHandle: null, - targetHandle: null, - }); - }); - - const updatedEdges = useFlowStore.getState().edges; - expect(updatedEdges).toHaveLength(1); - expect(updatedEdges[0]).toMatchObject({ - source: 'A', - target: 'B', - }); - }); -}); \ No newline at end of file diff --git a/test/pages/visProgPage/visualProgrammingUI/VisProgStores.test.tsx b/test/pages/visProgPage/visualProgrammingUI/VisProgStores.test.tsx new file mode 100644 index 0000000..66c0343 --- /dev/null +++ b/test/pages/visProgPage/visualProgrammingUI/VisProgStores.test.tsx @@ -0,0 +1,31 @@ +import { act } from '@testing-library/react'; +import useFlowStore from '../../../../src/pages/VisProgPage/visualProgrammingUI/VisProgStores.tsx'; +import { mockReactFlow } from '../../../setupFlowTests.ts'; + +beforeAll(() => { + mockReactFlow(); +}); + +describe('FlowStore Functionality', () => { + describe('ReactFlow onConnect', () => { + test('adds an edge when onConnect is triggered', () => { + const { onConnect} = useFlowStore.getState(); + + act(() => { + onConnect({ + source: 'A', + target: 'B', + sourceHandle: null, + targetHandle: null, + }); + }); + + const updatedEdges = useFlowStore.getState().edges; + expect(updatedEdges).toHaveLength(1); + expect(updatedEdges[0]).toMatchObject({ + source: 'A', + target: 'B', + }); + }); + }); +})