import React from 'react';
import { fireEvent } from '@testing-library/react';
import renderWithTheme from '../../../../testUtils/renderWithTheme';
import ActionButtons from '../index';
describe('ActionButtons', () => {
it('renders correctly', () => {
const { getByText } = renderWithTheme(
);
expect(getByText('Add')).toBeVisible();
expect(getByText('Secondary')).toBeVisible();
});
it('passes onClick to rendered buttons', () => {
const clickHandler = jest.fn();
const { getByText } = renderWithTheme(
);
fireEvent.click(getByText('Add'));
expect(clickHandler).toBeCalled();
});
it('throws error when there is no buttons', () => {
expect(() => renderWithTheme()).toThrow(
'[ActionButtons] Need at least 1 button to render'
);
});
it('throws error when there are more than 4 buttons', () => {
expect(() =>
renderWithTheme(
)
).toThrow('[ActionButtons] Maximum 4 buttons could be rendered');
});
it('throws error when there is no primary buttons', () => {
expect(() =>
renderWithTheme()
).toThrow('[ActionButtons] Need to have exactly 1 primary button');
});
it('throws error when there are more than 1 primary buttons', () => {
expect(() =>
renderWithTheme(
)
).toThrow('[ActionButtons] Need to have exactly 1 primary button');
});
});