Skip to content

Commit

Permalink
feat(project): add testUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
RCVZ committed Apr 29, 2021
1 parent b675390 commit b5cf3e2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/testUtils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { BrowserRouter as Router } from 'react-router-dom';
import React, { ReactNode, ReactElement } from 'react';
import { render, RenderOptions } from '@testing-library/react';

interface WrapperProps {
children?: ReactNode;
}

export const wrapper = ({ children }: WrapperProps) => (
<Router>{children}</Router>
);

const customRender = (ui: ReactElement, options?: RenderOptions) =>
render(ui, { wrapper, ...options });

export const mockWindowLocation = (path: string) => {
Object.defineProperty(window, 'location', {
value: {
pathname: path,
assign: jest.fn(),
},
});
};

export { customRender as render };

0 comments on commit b5cf3e2

Please sign in to comment.