This commit is contained in:
12
tests/helpers/renderWithRouter.tsx
Normal file
12
tests/helpers/renderWithRouter.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { ReactElement } from 'react';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { render } from '@testing-library/react';
|
||||
|
||||
type RenderWithRouterOptions = {
|
||||
route?: string;
|
||||
};
|
||||
|
||||
export function renderWithRouter(ui: ReactElement, options: RenderWithRouterOptions = {}) {
|
||||
const { route = '/' } = options;
|
||||
return render(<MemoryRouter initialEntries={[route]}>{ui}</MemoryRouter>);
|
||||
}
|
||||
Reference in New Issue
Block a user