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
32 lines
833 B
TypeScript
32 lines
833 B
TypeScript
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',
|
|
});
|
|
});
|
|
});
|
|
})
|