Files
twenty_crm/front/src/components/table/__tests__/EditableCell.test.tsx
2023-04-25 12:55:27 +02:00

18 lines
653 B
TypeScript

import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { RegularEditableCell } from '../__stories__/EditableCell.stories';
it('Checks the EditableCell editing event bubbles up', async () => {
const func = jest.fn(() => null);
const { getByTestId } = render(<RegularEditableCell changeHandler={func} />);
const parent = getByTestId('content-editable-parent');
expect(parent).not.toBeNull();
const editable = parent.querySelector('[contenteditable]');
expect(editable).not.toBeNull();
editable && userEvent.click(editable);
userEvent.keyboard('a');
expect(func).toBeCalled();
});