ant-design/components/auto-complete/__tests__/index.test.js

36 lines
965 B
JavaScript
Raw Normal View History

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 />
2018-12-07 16:17:45 +08:00
</AutoComplete>,
);
expect(wrapper.find('textarea').length).toBe(1);
wrapper.find('textarea').simulate('change', { target: { value: '123' } });
2018-12-07 16:17:45 +08:00
const dropdownWrapper = mount(
wrapper
.find('Trigger')
.instance()
.getComponent(),
);
2017-05-03 15:33:40 +08:00
// should not filter data source defaultly
2017-05-03 15:22:01 +08:00
expect(dropdownWrapper.find('MenuItem').length).toBe(3);
});
2017-08-17 15:33:26 +08:00
it('child.ref should work', () => {
const mockRef = jest.fn();
mount(
<AutoComplete dataSource={[]}>
<input ref={mockRef} />
2018-12-07 16:17:45 +08:00
</AutoComplete>,
2017-08-17 15:33:26 +08:00
);
expect(mockRef).toHaveBeenCalled();
});
});