2022-05-13 21:18:40 +03:00
|
|
|
import { ReactElement } from 'react';
|
|
|
|
import { render } from '@testing-library/react';
|
2022-07-10 00:03:21 +03:00
|
|
|
import userEvent from '@testing-library/user-event';
|
2022-05-13 21:18:40 +03:00
|
|
|
|
|
|
|
export const setUpCanvas = (element: ReactElement) => {
|
|
|
|
const result = render(element);
|
|
|
|
const { container } = result;
|
2022-05-28 13:54:33 +03:00
|
|
|
const getEvents = () => container.querySelector('canvas')?.getContext('2d')?.__getEvents(); // eslint-disable-line no-underscore-dangle
|
2022-05-13 21:18:40 +03:00
|
|
|
|
2022-05-28 13:54:33 +03:00
|
|
|
return { ...result, events: getEvents(), getEvents };
|
2022-05-13 21:18:40 +03:00
|
|
|
};
|
2022-07-10 00:03:21 +03:00
|
|
|
|
|
|
|
export const renderWithEvents = (element: ReactElement) => ({
|
|
|
|
user: userEvent.setup(),
|
|
|
|
...render(element),
|
|
|
|
});
|