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';
|
2022-12-26 03:52:48 +00:00
|
|
|
import { TRPCTestClientProvider } from './TRPCTestClientProvider';
|
2022-12-05 07:45:51 +00:00
|
|
|
|
2023-04-08 16:33:50 +00:00
|
|
|
const AllTheProviders: FC<{ children: React.ReactNode }> = ({ children }) => (
|
|
|
|
<TRPCTestClientProvider>
|
|
|
|
{children}
|
|
|
|
<Toaster />
|
|
|
|
</TRPCTestClientProvider>
|
|
|
|
);
|
2022-12-05 07:45:51 +00:00
|
|
|
|
|
|
|
const customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'wrapper'>) => render(ui, { wrapper: AllTheProviders, ...options });
|
|
|
|
const customRenderHook = (callback: () => any, options?: Omit<RenderOptions, 'wrapper'>) => renderHook(callback, { wrapper: AllTheProviders, ...options });
|
|
|
|
|
|
|
|
export * from '@testing-library/react';
|
|
|
|
export { customRender as render };
|
|
|
|
export { customRenderHook as renderHook };
|