Files
2026-01-28 10:34:36 +00:00

44 lines
1.7 KiB
TypeScript

// This program has been developed by students from the bachelor Computer Science at Utrecht
// University within the Software Project course.
// © Copyright Utrecht University (Department of Information and Computing Sciences)
import { jest } from '@jest/globals';
import React from 'react';
import '@testing-library/jest-dom';
/**
* Mock for @xyflow/react
* Provides simplified versions of React Flow hooks and components
*/
jest.mock('@xyflow/react', () => ({
useReactFlow: jest.fn(() => ({
screenToFlowPosition: jest.fn((pos: any) => pos),
getNode: jest.fn(),
getNodes: jest.fn(() => []),
getEdges: jest.fn(() => []),
setNodes: jest.fn(),
setEdges: jest.fn(),
})),
ReactFlowProvider: ({ children }: { children: React.ReactNode }) =>
React.createElement('div', { 'data-testid': 'react-flow-provider' }, children),
ReactFlow: ({ children, ...props }: any) =>
React.createElement('div', { 'data-testid': 'react-flow', ...props }, children),
Handle: ({ type, position, id }: any) =>
React.createElement('div', { 'data-testid': `handle-${type}-${id}`, 'data-position': position }),
Panel: ({ children, position }: any) =>
React.createElement('div', { 'data-testid': 'panel', 'data-position': position }, children),
Controls: () => React.createElement('div', { 'data-testid': 'controls' }),
Background: () => React.createElement('div', { 'data-testid': 'background' }),
}));
/**
* Mock for @neodrag/react
* Simplifies drag behavior for testing
*/
jest.mock('@neodrag/react', () => ({
useDraggable: jest.fn((ref: any, options?: any) => {
// Store the options so we can trigger them in tests
if (ref && ref.current) {
(ref.current as any)._dragOptions = options;
}
}),
}));