Files
video-short-converter/__tests__/test-utils.tsx.bak

35 lines
883 B
TypeScript

import React, { ReactElement } from 'react';
import { render, RenderOptions } from '@testing-library/react';
import { AppRouterContext } from 'next/dist/shared/lib/app-router-context.shared-runtime';
const mockRouter = {
push: jest.fn(),
prefetch: jest.fn(),
replace: jest.fn(),
back: jest.fn(),
forward: jest.fn(),
refresh: jest.fn(),
beforePopState: jest.fn(),
events: {
on: jest.fn(),
off: jest.fn(),
emit: jest.fn(),
},
} as any;
const AllTheProviders = ({ children }: { children: React.ReactNode }) => {
return (
<AppRouterContext.Provider value={mockRouter}>
{children}
</AppRouterContext.Provider>
);
};
const customRender = (
ui: ReactElement,
options?: Omit<RenderOptions, 'wrapper'>
) => render(ui, { wrapper: AllTheProviders, ...options });
export * from '@testing-library/react';
export { customRender as render };