import React from 'react';
import {act, render} from '../../test-utils';
import {BackButton} from '../index';
import {Size} from '../../types'
import 'jest-styled-components';




describe('<BackButton />', () => {
  it('should render back button', function () {
    const {queryByText} = render(<BackButton size={Size.Small}>Back Button</BackButton>);
    expect(queryByText('Back Button')).toBeDefined();
  });
  it('should call action on click', function () {
    const clickMock = jest.fn(() => {});
    const component = render(<BackButton size={Size.Small} onClick={clickMock}>Back Button</BackButton>);
    act(() => {
      component.getByText('Back Button').click();
    });
    expect(clickMock).toBeCalled();
  });
  it('should not call action on click when disabled', function () {
    const clickMock = jest.fn(() => {});
    const component = render(<BackButton size={Size.Small} disabled={true} onClick={clickMock}>Back Button</BackButton>);
    act(() => {
      component.getByText('Back Button').click();
    });
    expect(clickMock).toBeCalledTimes(0);
  });

});
