import { cleanup, fireEvent } from '@testing-library/react';
import { ASSETS_URL } from '../../../consts/common';
import { ThemeProvider } from '../../@styles/theme-provider';
import { render } from '../../../utils/theme-render-wrapper';
import {
RenderActionButtonsCell,
RenderAvatarGroupCell,
RenderTextGroupCell,
RenderTextListCell
} from '../card-grid';
import Card from './card';
import type { CardProps } from './types';
afterEach(cleanup);
const actionViewHandler = jest.fn();
const cellClickHandler = jest.fn();
const mockRowId = 'mockRowId';
const mockGroupCard: CardProps = {
columns: [
{
field: 'groupName',
children: (
),
flex: 'auto',
minWidth: 224,
maxWidth: 398
},
{
field: 'members',
children: (
),
width: 152
},
{
field: 'groups',
children: (
),
width: 232
},
{
field: 'actionButtons',
children: (
actionViewHandler
}
],
field: 'actionButtons'
}}
row={{
id: mockRowId
}}
/>
),
align: 'end',
hideDivider: true,
marginLeft: 'auto',
minWidth: 120,
width: 120
}
],
onCellClick: cellClickHandler
};
describe('', () => {
it('should render successfully', () => {
const { baseElement } = render(
);
expect(baseElement).toBeTruthy();
});
it('should render children, focus and blur', () => {
const { baseElement, getByRole } = render(Lorem Ipsum);
fireEvent.blur(baseElement);
const rowEl = getByRole('row');
fireEvent.focus(rowEl);
fireEvent.blur(rowEl);
});
it('should render mock and click twice', () => {
const { getAllByRole, getByTestId } = render(
);
const firstCellEl = getAllByRole('cell')[0];
firstCellEl.click();
expect(cellClickHandler).toHaveBeenCalled();
const actionViewEl = getByTestId(`${mockRowId}_view`);
actionViewEl.click();
expect(actionViewHandler).toHaveBeenCalled();
});
});