import React from 'react';
import { cleanup } from '@testing-library/react';
import { render } from '../../../utils/theme-render-wrapper';
import { RadioButtons } from './radio-buttons';

afterEach(cleanup);

const items = [
  {
    text: 'Button1',
    selected: false
  },
  {
    text: 'Button2',
    selected: false
  },
  {
    text: 'Button3',
    selected: false
  }
];

const clickHandler = jest.fn();

describe('<RadioButtons />', () => {
  it(`Should render RadioButtons and click on a button`, () => {
    const { queryByTestId } = render(<RadioButtons items={items} clickHandler={clickHandler} />);

    const buttonEl = queryByTestId(items[0].text);
    buttonEl?.click();

    expect(clickHandler).toHaveBeenCalled();
  });
});
