2022-12-05 07:45:51 +00:00
|
|
|
import React, { FC, ReactElement } from 'react';
|
|
|
|
import { render, RenderOptions, renderHook } from '@testing-library/react';
|
2023-04-08 16:33:50 +00:00
|
|
|
import { Toaster } from 'react-hot-toast';
|
2023-05-06 14:03:07 +00:00
|
|
|
import { NextIntlProvider } from 'next-intl';
|
2023-06-07 19:15:10 +00:00
|
|
|
import ue from '@testing-library/user-event';
|
2023-05-06 14:03:07 +00:00
|
|
|
import messages from '../src/client/messages/en.json';
|
2022-12-05 07:45:51 +00:00
|
|
|
|
2023-06-07 19:15:10 +00:00
|
|
|
const userEvent = ue.setup();
|
|
|
|
|
2023-04-08 16:33:50 +00:00
|
|
|
const AllTheProviders: FC<{ children: React.ReactNode }> = ({ children }) => (
|
2023-05-06 14:03:07 +00:00
|
|
|
<NextIntlProvider locale="en" messages={messages}>
|
2023-10-06 06:55:31 +00:00
|
|
|
{children}
|
|
|
|
<Toaster />
|
2023-05-06 14:03:07 +00:00
|
|
|
</NextIntlProvider>
|
2023-04-08 16:33:50 +00:00
|
|
|
);
|
2022-12-05 07:45:51 +00:00
|
|
|
|
|
|
|
const customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'wrapper'>) => render(ui, { wrapper: AllTheProviders, ...options });
|
2023-10-06 06:55:31 +00:00
|
|
|
const customRenderHook = <Props, Result>(callback: (props: Props) => Result, options?: Omit<RenderOptions, 'wrapper'>) => renderHook(callback, { wrapper: AllTheProviders, ...options });
|
2022-12-05 07:45:51 +00:00
|
|
|
|
|
|
|
export * from '@testing-library/react';
|
|
|
|
export { customRender as render };
|
|
|
|
export { customRenderHook as renderHook };
|
2023-06-07 19:15:10 +00:00
|
|
|
export { userEvent };
|