shlink-web-client/test/__mocks__/setUpCanvas.ts

11 lines
408 B
TypeScript
Raw Normal View History

import { ReactElement } from 'react';
import { render } from '@testing-library/react';
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 };
};