mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
31 lines
923 B
JavaScript
31 lines
923 B
JavaScript
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);
|
|
});
|
|
|
|
it('child.ref should work', () => {
|
|
const mockRef = jest.fn();
|
|
mount(
|
|
<AutoComplete dataSource={[]}>
|
|
<input ref={mockRef} />
|
|
</AutoComplete>
|
|
);
|
|
expect(mockRef).toHaveBeenCalled();
|
|
});
|
|
});
|