import { ReactElement, ReactNode } from 'react'; import { render, renderHook } from '@testing-library/react'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { MemoryRouter } from 'react-router'; export function makeClient(): QueryClient { return new QueryClient({ defaultOptions: { queries: { retry: false }, mutations: { retry: false }, }, }); } export function Providers({ children, client = makeClient(), route = '/admin/dashboard', }: { children: ReactNode; client?: QueryClient; route?: string; }) { return ( {children} ); } export function renderWithProviders(ui: ReactElement, opts?: { route?: string }) { const client = makeClient(); return { client, ...render(ui, { wrapper: ({ children }) => ( {children} ), }), }; } export function renderHookWithClient(cb: () => T) { const client = makeClient(); return renderHook(cb, { wrapper: ({ children }) => ( {children} ), }); }