import React from 'react';
import Adapter from 'enzyme-adapter-react-16';
import Enzyme, { shallow } from 'enzyme';
import Input from './index';
Enzyme.configure({
  adapter: new Adapter()
});
describe('<Input />', function () {
  test('正确渲染', function () {
    var wrapper = shallow(React.createElement(Input, {
      placeholder: "placeholder",
      defaultValue: "\u9ED8\u8BA4\u8F93\u5165",
      showDeleteBtn: true
    }));
    expect(wrapper).toMatchSnapshot();
  });
  test('输入', function () {
    var wrapper = shallow(React.createElement(Input, {
      placeholder: "placeholder",
      defaultValue: "\u9ED8\u8BA4\u8F93\u5165",
      showDeleteBtn: true
    }));
    wrapper.find('.ne-input-delete').simulate('click');
    wrapper.find('input').simulate('change', {
      target: {
        value: '测试'
      }
    });
    expect(wrapper.find('input').prop('value')).toBe('测试');
  });
  test('默认值', function () {
    var wrapper = shallow(React.createElement(Input, {
      placeholder: "placeholder",
      defaultValue: "\u9ED8\u8BA4\u8F93\u5165",
      showDeleteBtn: true
    }));
    expect(wrapper.find('input').prop('value')).toBe('默认输入');
  });
  test('清空输入内容', function () {
    var wrapper = shallow(React.createElement(Input, {
      placeholder: "placeholder",
      defaultValue: "\u9ED8\u8BA4\u8F93\u5165",
      showDeleteBtn: true
    }));
    wrapper.find('.ne-input-delete').simulate('click');
    expect(wrapper.find('input').prop('value')).toBe('');
    expect(wrapper.find('.ne-input-delete').length).toBe(0);
  });
});