import React from 'react';
import { fireEvent } from '@testing-library/react';
import renderWithTheme from '../../../../testUtils/renderWithTheme';
import BulkActions from '../index';
describe('BulkActions', () => {
it('renders correctly', () => {
const { getByText } = renderWithTheme(
);
expect(getByText('Selected rows')).toBeVisible();
expect(getByText('1')).toBeVisible();
});
it('shows actions dropdown when click icon', async () => {
const { queryByText, findByText, getByRole } = renderWithTheme(
);
expect(queryByText('View')).not.toBeInTheDocument();
fireEvent.click(getByRole('button'));
expect(await findByText('View')).toBeInTheDocument();
});
it('passes selected data to action click handler', () => {
const clickHandler = jest.fn();
const { getByText, getByRole } = renderWithTheme(
);
fireEvent.click(getByRole('button'));
fireEvent.click(getByText('View'));
expect(clickHandler).toHaveBeenCalledWith([{ name: 'Teng', age: 30 }]);
});
it('renders divider corectly', () => {
const { getByTestId, queryByTestId, getByRole } = renderWithTheme(
);
fireEvent.click(getByRole('button'));
expect(getByTestId('divider-bottom')).toBeInTheDocument();
expect(queryByTestId('divider-top')).not.toBeInTheDocument();
});
});