2019-01-12 03:33:27 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import Vue from 'vue';
|
|
|
|
import AutoComplete from '..';
|
|
|
|
import focusTest from '../../../tests/shared/focusTest';
|
2018-05-18 13:09:52 +00:00
|
|
|
|
|
|
|
describe('AutoComplete with Custom Input Element Render', () => {
|
2019-01-12 03:33:27 +00:00
|
|
|
focusTest(AutoComplete);
|
|
|
|
function $$(className) {
|
|
|
|
return document.body.querySelectorAll(className);
|
2018-05-18 13:09:52 +00:00
|
|
|
}
|
2019-01-12 03:33:27 +00:00
|
|
|
it('AutoComplete with custom Input render perfectly', done => {
|
|
|
|
const wrapper = mount(
|
|
|
|
{
|
2019-02-01 09:23:00 +00:00
|
|
|
render() {
|
2019-01-12 03:33:27 +00:00
|
|
|
return (
|
|
|
|
<AutoComplete ref="component" dataSource={['12345', '23456', '34567']}>
|
|
|
|
<input />
|
|
|
|
</AutoComplete>
|
|
|
|
);
|
|
|
|
},
|
2018-05-18 13:09:52 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
{ attachToDocument: true, sync: false },
|
|
|
|
);
|
|
|
|
expect(wrapper.findAll('input').length).toBe(1);
|
|
|
|
const input = wrapper.find('input');
|
|
|
|
input.element.value = '123';
|
|
|
|
input.trigger('input');
|
2018-05-18 13:09:52 +00:00
|
|
|
Vue.nextTick(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
mount(
|
|
|
|
{
|
|
|
|
render() {
|
|
|
|
return wrapper.find({ name: 'Trigger' }).vm.getComponent();
|
|
|
|
},
|
2018-05-30 06:12:43 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
{ sync: false },
|
|
|
|
);
|
2018-05-30 06:12:43 +00:00
|
|
|
Vue.nextTick(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect($$('.ant-select-dropdown-menu-item').length).toBe(3);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|