ant-design/components/auto-complete/__tests__/index.test.js
Wei Zhu 9678d3fcfd
Focus && blur support (#8204)
* Add test for select

* Add focus() and blur() for AutoComplete

* Add focus() and blur() to Cascader

* Add focus test for input

* Add focus() and blur() for Checkbox

* Add focus() and blur() for Radio

* Add focus() and blur() for Switch

* Add blur() for TimePicker

* Add focus() and blur() to TreeSelect
2017-11-19 01:41:40 +08:00

34 lines
1008 B
JavaScript

import React from 'react';
import { mount } from 'enzyme';
import AutoComplete from '..';
import focusTest from '../../../tests/shared/focusTest';
describe('AutoComplete with Custom Input Element Render', () => {
focusTest(AutoComplete);
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();
});
});