mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-06-19 13:21:46 +00:00
27 lines
832 B
TypeScript
27 lines
832 B
TypeScript
import React from 'react';
|
|
import { render, type RenderOptions } from '@testing-library/react';
|
|
import { MemoryRouter } from 'react-router-dom';
|
|
import { TranslationProvider } from '../../src/i18n/TranslationContext';
|
|
|
|
interface RenderWithProvidersOptions extends Omit<RenderOptions, 'wrapper'> {
|
|
initialEntries?: string[];
|
|
}
|
|
|
|
function renderWithProviders(
|
|
ui: React.ReactElement,
|
|
{ initialEntries = ['/'], ...options }: RenderWithProvidersOptions = {},
|
|
) {
|
|
function Wrapper({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<MemoryRouter initialEntries={initialEntries}>
|
|
<TranslationProvider>{children}</TranslationProvider>
|
|
</MemoryRouter>
|
|
);
|
|
}
|
|
|
|
return render(ui, { wrapper: Wrapper, ...options });
|
|
}
|
|
|
|
export * from '@testing-library/react';
|
|
export { renderWithProviders as render };
|