refactor: reorganize repo docs and tooling layout
Consolidate the repository into clearer apps, tools, and layered docs areas so contributors can navigate and maintain it more reliably. Align validation, metadata sync, and CI around the same canonical workflow to reduce drift across local checks and GitHub Actions.
This commit is contained in:
43
apps/web-app/src/utils/testUtils.tsx
Normal file
43
apps/web-app/src/utils/testUtils.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import React from 'react';
|
||||
import { render, RenderOptions } from '@testing-library/react';
|
||||
import { MemoryRouter, Routes, Route } from 'react-router-dom';
|
||||
import { SkillProvider } from '../context/SkillContext';
|
||||
|
||||
// Custom render with router and SkillProvider
|
||||
interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
|
||||
route?: string;
|
||||
path?: string; // The route pattern, e.g., /skill/:id
|
||||
useProvider?: boolean;
|
||||
}
|
||||
|
||||
export function renderWithRouter(
|
||||
ui: React.ReactElement,
|
||||
{
|
||||
route = '/',
|
||||
path = '*',
|
||||
useProvider = true,
|
||||
...renderOptions
|
||||
}: CustomRenderOptions = {}
|
||||
): ReturnType<typeof render> {
|
||||
return render(ui, {
|
||||
wrapper: ({ children }) => (
|
||||
<MemoryRouter initialEntries={[route]}>
|
||||
{useProvider ? (
|
||||
<SkillProvider>
|
||||
<Routes>
|
||||
<Route path={path} element={children} />
|
||||
</Routes>
|
||||
</SkillProvider>
|
||||
) : (
|
||||
<Routes>
|
||||
<Route path={path} element={children} />
|
||||
</Routes>
|
||||
)}
|
||||
</MemoryRouter>
|
||||
),
|
||||
...renderOptions,
|
||||
});
|
||||
}
|
||||
|
||||
// Re-export everything from testing-library
|
||||
export * from '@testing-library/react';
|
||||
Reference in New Issue
Block a user