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

35 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { mount } from '@vue/test-utils';
2020-10-24 06:36:06 +00:00
import { sleep } from '../../../tests/utils';
2019-01-12 03:33:27 +00:00
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
}
2020-10-24 06:36:06 +00:00
it('AutoComplete with custom Input render perfectly', async () => {
2019-01-12 03:33:27 +00:00
const wrapper = mount(
{
2019-02-01 09:23:00 +00:00
render() {
2019-01-12 03:33:27 +00:00
return (
2021-06-24 03:03:02 +00:00
<AutoComplete
ref="component"
options={[{ value: '12345' }, { value: '23456' }, { value: '34567' }]}
>
2019-01-12 03:33:27 +00:00
<input />
</AutoComplete>
);
},
2018-05-18 13:09:52 +00:00
},
2020-07-25 07:46:49 +00:00
{ attachTo: 'body', sync: false },
2019-01-12 03:33:27 +00:00
);
expect(wrapper.findAll('input').length).toBe(1);
const input = wrapper.find('input');
input.element.value = '123';
input.trigger('input');
2020-10-24 06:36:06 +00:00
await sleep();
expect($$('.ant-select-item-option').length).toBe(3);
2019-01-12 03:33:27 +00:00
});
});