import React from 'react';

import Button from './index';

const mockCallback = jest.fn();
const data = {
  handleClick: mockCallback,
};

describe('Button', () => {
  const defaultElement = <Button {...data}>Button</Button>;
  let wrapper;

  beforeEach(() => {
    wrapper = shallow(defaultElement);
  });

  it('should render correctly', () => {
    expect(wrapper).toMatchSnapshot();
  });

  it('should render with different types', () => {
    expect(wrapper.setProps({ type: 'submit' })).toMatchSnapshot();
    expect(wrapper.setProps({ type: 'reset' })).toMatchSnapshot();
  });

  it('should render with throbber', () => {
    expect(wrapper.setProps({ showThrobber: true })).toMatchSnapshot();
  });

  it('should fire onClick event', () => {
    wrapper.find('button').simulate('click');
    expect(mockCallback.mock.calls.length).toBe(1);
  });

  it('should render with a size', () => {
    expect(wrapper.setProps({ size: 'small' })).toMatchSnapshot();
  });
});
