import { describe, it, beforeEach } from '@jest/globals'; import { screen } from '@testing-library/react'; import { renderWithProviders, resetFlowStore } from '../.././/./../../test-utils/test-utils'; import StartNode, { StartReduce, StartConnects } from '../../../../../src/pages/VisProgPage/visualProgrammingUI/nodes/StartNode'; import type { Node } from '@xyflow/react'; import '@testing-library/jest-dom'; describe('StartNode', () => { beforeEach(() => { resetFlowStore(); }); describe('Rendering', () => { it('renders the StartNode correctly', () => { const mockNode: Node = { id: 'start-1', type: 'start', // TypeScript now knows this is a string position: { x: 0, y: 0 }, data: { label: 'Start Node', droppable: false, hasReduce: true, }, }; renderWithProviders( ); expect(screen.getByText('Start')).toBeInTheDocument(); // The handle should exist in the DOM expect(document.querySelector('[data-handleid="source"]')).toBeInTheDocument(); }); }); describe('StartReduce Function', () => { it('reduces the StartNode to its minimal structure', () => { const mockNode: Node = { id: 'start-1', type: 'start', position: { x: 0, y: 0 }, data: { label: 'Start Node', droppable: false, hasReduce: true, }, }; const result = StartReduce(mockNode, [mockNode]); expect(result).toEqual({ id: 'start-1' }); }); }); describe('StartConnects Function', () => { it('handles connections without throwing', () => { const startNode: Node = { id: 'start-1', type: 'start', position: { x: 0, y: 0 }, data: { label: 'Start Node', droppable: false, hasReduce: true, }, }; const otherNode: Node = { id: 'norm-1', type: 'norm', position: { x: 100, y: 0 }, data: { label: 'Norm Node', droppable: true, norm: 'test', hasReduce: true, }, }; expect(() => StartConnects(startNode, otherNode, true)).not.toThrow(); expect(() => StartConnects(startNode, otherNode, false)).not.toThrow(); }); }); });