Download web/src/test/utils.tsx from EnergyVenom/patch-testing-coworker: direct link, hf CLI and curl.
- Browser
- Download file 978 Bytes
-
https://huggingface.co/spaces/EnergyVenom/patch-testing-coworker/resolve/main/web/src/test/utils.tsx
- Command line
-
hf download hf://spaces/EnergyVenom/patch-testing-coworker/web/src/test/utils.tsx
-
curl -L -o utils.tsx https://huggingface.co/spaces/EnergyVenom/patch-testing-coworker/resolve/main/web/src/test/utils.tsx
978 Bytes
| import { MantineProvider } from '@mantine/core'; | |
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | |
| import { render } from '@testing-library/react'; | |
| import type { ReactElement } from 'react'; | |
| import { MemoryRouter } from 'react-router-dom'; | |
| import { AuthProvider } from '../auth/AuthContext'; | |
| export function renderUi(ui: ReactElement, { route = '/', auth = false }: { route?: string; auth?: boolean } = {}) { | |
| const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } }); | |
| const inner = auth ? <AuthProvider>{ui}</AuthProvider> : ui; | |
| return render( | |
| <MantineProvider> | |
| <QueryClientProvider client={qc}> | |
| <MemoryRouter initialEntries={[route]}>{inner}</MemoryRouter> | |
| </QueryClientProvider> | |
| </MantineProvider>, | |
| ); | |
| } | |
| export function jsonResponse(body: unknown, status = 200) { | |
| return new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } }); | |
| } | |