shlink-web-client/test/__helpers__/setUpTest.ts
2023-02-18 10:40:37 +01:00

16 lines
582 B
TypeScript

import type { ReactElement } from 'react';
import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
export const setUpCanvas = (element: ReactElement) => {
const result = render(element);
const { container } = result;
const getEvents = () => container.querySelector('canvas')?.getContext('2d')?.__getEvents(); // eslint-disable-line no-underscore-dangle
return { ...result, events: getEvents(), getEvents };
};
export const renderWithEvents = (element: ReactElement) => ({
user: userEvent.setup(),
...render(element),
});