refactor(web-app): migrate to TypeScript, add security fix and test suite
This commit is contained in:
25
web-app/src/utils/testUtils.tsx
Normal file
25
web-app/src/utils/testUtils.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import { render, RenderOptions } from '@testing-library/react';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
|
||||
// Custom render with router
|
||||
interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
|
||||
route?: string;
|
||||
}
|
||||
|
||||
export function renderWithRouter(
|
||||
ui: React.ReactElement,
|
||||
{ route = '/', ...renderOptions }: CustomRenderOptions = {}
|
||||
): ReturnType<typeof render> {
|
||||
window.history.pushState({}, 'Test page', route);
|
||||
|
||||
return render(ui, {
|
||||
wrapper: ({ children }) => (
|
||||
<BrowserRouter>{children}</BrowserRouter>
|
||||
),
|
||||
...renderOptions,
|
||||
});
|
||||
}
|
||||
|
||||
// Re-export everything from testing-library
|
||||
export * from '@testing-library/react';
|
||||
Reference in New Issue
Block a user