UNPKG

react-antd-admin-panel

Version:

Modern TypeScript-first React admin panel builder with Ant Design 6

58 lines 1.89 kB
import React from 'react'; import { GlobalStore } from '../main/Store'; import { UserState } from '../main/UserState'; import type { MainInstance, MainConfig } from '../main/types'; import type { User } from '../types'; import { MockHttp } from './createMockHttp'; /** * createMockMain - Create a mock MainProvider wrapper for testing * * @example * import { createMockMain } from 'react-antd-admin-panel/testing'; * import { render, screen } from '@testing-library/react'; * * const { wrapper, mockNavigate, mockHttp } = createMockMain({ * user: { id: '1', name: 'Test User', roles: ['admin'] }, * config: { pathToApi: '/api' } * }); * * render(<MyComponent />, { wrapper }); * expect(screen.getByText('Hello')).toBeInTheDocument(); */ /** Mock function interface compatible with Jest/Vitest */ export interface MockFunction { (...args: any[]): any; mock: { calls: any[][]; }; mockClear: () => void; } export interface MockMainOptions { /** Initial user data */ user?: User; /** Initial store values */ store?: Record<string, any>; /** Main configuration overrides */ config?: Partial<MainConfig['config']>; } export interface MockMainResult { /** React wrapper component for testing-library */ wrapper: React.FC<{ children: React.ReactNode; }>; /** Mock navigate function spy */ mockNavigate: MockFunction; /** Mock HTTP instance */ mockHttp: MockHttp; /** Direct access to the mock Main instance */ mainInstance: MainInstance; /** Direct access to UserState for manipulation */ userState: UserState; /** Direct access to GlobalStore for manipulation */ store: GlobalStore; } /** * Create a mock Main context wrapper for testing */ export declare function createMockMain(options?: MockMainOptions): MockMainResult; //# sourceMappingURL=createMockMain.d.ts.map