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

import TextArea from '.';

describe('TextArea', () => {
  it('displays a TextArea', () => {
    const node = mount(<TextArea />);
    expect(node.find('textarea').hasClass('TextArea')).toBe(true);
  });

  it('TextArea resizes horizontally and vertically', () => {
    const node = mount(<TextArea resize="both" />);
    expect(node.find('textarea').hasClass('TextArea_both')).toBe(true);
  });

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