diff --git a/packages/components/select/__tests__/select.test.ts b/packages/components/select/__tests__/select.test.ts index c66437e80b..4ca68385db 100644 --- a/packages/components/select/__tests__/select.test.ts +++ b/packages/components/select/__tests__/select.test.ts @@ -323,8 +323,9 @@ describe('Select', () => { DEFAULT_PLACEHOLDER ) const select = wrapper.findComponent({ name: 'ElSelect' }) - await select.trigger('mouseenter') - await select.trigger('click') + const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`) + await trigger.trigger('mouseenter') + await trigger.trigger('click') await nextTick() expect((select.vm as any).expanded).toBe(true) }) @@ -1592,8 +1593,9 @@ describe('Select', () => { () => ({ value: 'test' }) ) const vm = wrapper.vm as any - await wrapper.trigger('mouseenter') - await wrapper.trigger('click') + const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`) + await trigger.trigger('mouseenter') + await trigger.trigger('click') const selectVm = wrapper.findComponent({ name: 'ElSelect' }).vm as any expect(selectVm.expanded).toBe(true) expect(wrapper.find(`.${PLACEHOLDER_CLASS_NAME}`).text()).toBe('test') @@ -1673,9 +1675,9 @@ describe('Select', () => { value: 'test', }) ) - const select = wrapper.findComponent({ name: 'ElSelect' }) - await select.trigger('mouseenter') - await select.trigger('click') + const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`) + await trigger.trigger('mouseenter') + await trigger.trigger('click') await nextTick() expect( !!(document.querySelector('.el-select__popper') as HTMLElement).style @@ -2196,9 +2198,10 @@ describe('Select', () => { clearable: true, }) const select = wrapper.findComponent({ name: 'ElSelect' }) - await select.trigger('click') + const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`) + await trigger.trigger('click') expect((select.vm as any).expanded).toBe(true) - await select.trigger('click') + await trigger.trigger('click') expect((select.vm as any).expanded).toBe(false) }) @@ -2208,11 +2211,11 @@ describe('Select', () => { clearable: true, }) const select = wrapper.findComponent({ name: 'ElSelect' }) - - await select.trigger('click') + const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`) + await trigger.trigger('click') expect((select.vm as any).expanded).toBe(true) - await select.trigger('click') + await trigger.trigger('click') expect((select.vm as any).expanded).toBe(false) }) diff --git a/packages/components/select/src/select.vue b/packages/components/select/src/select.vue index 543d682478..f86d40d226 100644 --- a/packages/components/select/src/select.vue +++ b/packages/components/select/src/select.vue @@ -5,7 +5,6 @@ :class="[nsSelect.b(), nsSelect.m(selectSize)]" @[mouseEnterEventName]="states.inputHovering = true" @mouseleave="states.inputHovering = false" - @click.prevent.stop="toggleMenu" >
{ document.documentElement.innerHTML = '' }) +const WRAPPER_CLASS_NAME = 'el-select__wrapper' const PLACEHOLDER_CLASS_NAME = 'el-select__placeholder' describe('TimeSelect', () => { @@ -137,7 +138,8 @@ describe('TimeSelect', () => { }) wrapper.findComponent(TimeSelect).vm.$.exposed!.focus() - await wrapper.findComponent(TimeSelect).trigger('click') + const trigger = wrapper.find(`.${WRAPPER_CLASS_NAME}`) + await trigger.trigger('click') await nextTick() await nextTick()