import { mount } from '@vue/test-utils'; import { asyncExpect } from '@/tests/utils'; import Select from '..'; import CloseOutlined from '@ant-design/icons-vue/CloseOutlined'; import focusTest from '../../../tests/shared/focusTest'; import mountTest from '../../../tests/shared/mountTest'; function $$(className) { return document.body.querySelectorAll(className); } function getStyle(el, prop) { const style = window.getComputedStyle ? window.getComputedStyle(el) : el.currentStyle; // If a css property's value is `auto`, it will return an empty string. return prop ? style[prop] : style; } describe('Select', () => { beforeEach(() => { document.body.innerHTML = ''; }); focusTest(Select); mountTest({ render() { return (
1 ); }, }, { sync: false, attachTo: 'body' }, ); await asyncExpect(() => { expect(getStyle($$('.ant-select-dropdown')[0], 'display')).toBe('block'); }, 100); await asyncExpect(() => { wrapper.findAll('.ant-select-selector')[0].element.dispatchEvent(new MouseEvent('mousedown')); }); await asyncExpect(() => { expect(onDropdownVisibleChange).toHaveBeenLastCalledWith(false); }); await asyncExpect(() => { expect(getStyle($$('.ant-select-dropdown')[0], 'display')).toBe('block'); wrapper.setProps({ open: false }); }); await asyncExpect(() => { expect(getStyle($$('.ant-select-dropdown')[0], 'display')).toBe('none'); wrapper.findAll('.ant-select-selector')[0].element.dispatchEvent(new MouseEvent('mousedown')); expect(onDropdownVisibleChange).toHaveBeenLastCalledWith(true); expect(getStyle($$('.ant-select-dropdown')[0], 'display')).toBe('none'); }, 500); }); describe('Select Custom Icons', () => { it('should support customized icons', () => { const wrapper = mount({ render() { return ( ); }, }); expect(wrapper.html()).toMatchSnapshot(); }); }); });