@kadconsulting/dry
Version:
KAD Reusable Component Library
29 lines • 1.06 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { render, fireEvent } from '@testing-library/react';
import CheckboxGroup from './CheckBoxGroup';
const mockOptions = [
{
LabelContent: 'Option 1',
checked: false,
color: 'light-contrast',
},
{
LabelContent: 'Option 2',
checked: false,
color: 'light-contrast',
},
];
describe('CheckboxGroup', () => {
it('renders correctly', () => {
const { getByText } = render(_jsx(CheckboxGroup, { name: 'testGroup', options: mockOptions }));
expect(getByText('Option 1')).toBeInTheDocument();
expect(getByText('Option 2')).toBeInTheDocument();
});
it('handles onChange', () => {
const handleChange = jest.fn();
const { getByLabelText } = render(_jsx(CheckboxGroup, { name: 'testGroup', options: mockOptions }));
fireEvent.click(getByLabelText('Option 1'));
expect(handleChange).toHaveBeenCalledWith(expect.any(Object), 'Option 1');
});
});
//# sourceMappingURL=CheckboxGroup.test.js.map