import React from 'react';
import { mount } from 'enzyme';

import Input from '.';

describe('Input', () => {
  it('displays an input', () => {
    const node = mount(<Input id="some-input" />);
    expect(node.getDOMNode().classList).toContain('Input');
  });

  it('displays a large input', () => {
    const node = mount(<Input size="lg" />);
    expect(node.find('input').hasClass('Input_lg')).toBe(true);
  });

  it('should call the onChange handler', () => {
    const onChangeMock = jest.fn();
    const node = mount(<Input onChange={onChangeMock} value="hello" />);
    expect(node.state().value).toBe('hello');
    node.find('input').simulate('change', { target: { value: 'test' } });
    expect(onChangeMock).toHaveBeenCalled();
  });
});
