import React from 'react';
import { cleanup } from '@testing-library/react';
import { render } from '../../utils/theme-render-wrapper';
import { SegmentedTabs } from './segmented-tabs';

afterEach(cleanup);
describe('<SegmentedTabs />', () => {
  it(`Should render SegmentedTabs and click on one of them`, () => {
    const buttons = [
      { text: 'Button1', selected: false },
      { text: 'Button2', selected: false },
      { text: 'Button3', selected: false }
    ];

    const clickHandler = jest.fn();

    const { queryByTestId } = render(<SegmentedTabs clickHandler={clickHandler} items={buttons} />);

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

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