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

describe('AutoComplete with Custom Input Element Render', () => {
  it('AutoComplete with custom Input render perfectly', () => {
    const wrapper = mount(
      <AutoComplete dataSource={['12345', '23456', '34567']}>
        <textarea />
      </AutoComplete>,
    );

    expect(wrapper.find('textarea').length).toBe(1);
    wrapper.find('textarea').simulate('change', { target: { value: '123' } });
    const dropdownWrapper = mount(
      wrapper
        .find('Trigger')
        .instance()
        .getComponent(),
    );

    // should not filter data source defaultly
    expect(dropdownWrapper.find('MenuItem').length).toBe(3);
  });
});

@@ -727,13 +727,1009 @@
 );%0A  %7D);
+%0A%0A  it('AutoComplete should work when dataSource is object array', () =%3E %7B%0A    const wrapper = mount(%0A      %3CAutoComplete dataSource=%7B%5B%7B text: 'text', value: 'value' %7D, %7B text: 'abc', value: 'xxx' %7D%5D%7D%3E%0A        %3Cinput /%3E%0A      %3C/AutoComplete%3E,%0A    );%0A    expect(wrapper.find('input').length).toBe(1);%0A    wrapper.find('input').simulate('change', %7B target: %7B value: 'a' %7D %7D);%0A    const dropdownWrapper = mount(%0A      wrapper%0A        .find('Trigger')%0A        .instance()%0A        .getComponent(),%0A    );%0A%0A    // should not filter data source defaultly%0A    expect(dropdownWrapper.find('MenuItem').length).toBe(2);%0A  %7D);%0A%0A  it('AutoComplete throws error when contains invalid dataSource', () =%3E %7B%0A    jest.spyOn(console, 'error').mockImplementation(() =%3E undefined);%0A    expect(() =%3E %7B%0A      mount(%0A        %3CAutoComplete dataSource=%7B%5B() =%3E %7B%7D%5D%7D%3E%0A          %3Ctextarea /%3E%0A        %3C/AutoComplete%3E,%0A      );%0A    %7D).toThrow();%0A    // eslint-disable-next-line no-console%0A    console.error.mockRestore();%0A  %7D);
 %0A%7D);%0A

Add test case for AutoComplete