mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-27 03:01:14 +08:00
df57ddfe39
- Fix the issue that dropdown with trigger 'click' cannot be closed when clicking outside content - Fix the same issue for popover popconfirm - Remove useless code from `el-tooltip-content` which can be much simpler - Use `onClick` to replace `onMousedown` because `onMousedown` is triggered prior than `onClick` - Adjust test cases against these changes above
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import { nextTick, ref } from 'vue'
|
|
import makeMount from '@element-plus/test-utils/make-mount'
|
|
import { rAF } from '@element-plus/test-utils/tick'
|
|
import Popover from '../src/index.vue'
|
|
import PopoverDirective, { VPopover } from '../src/directive'
|
|
|
|
const AXIOM = 'Rem is the best girl'
|
|
|
|
const Comp = {
|
|
template: `
|
|
<el-popover ref="popoverRef" title="title" :content="content" virtual-triggering trigger="click" />
|
|
<div v-popover="popoverRef" id="reference-node">
|
|
trigger
|
|
</div>
|
|
`,
|
|
components: {
|
|
[Popover.name]: Popover,
|
|
},
|
|
setup() {
|
|
return {
|
|
popoverRef: ref(null),
|
|
content: AXIOM,
|
|
}
|
|
},
|
|
}
|
|
|
|
const mount = makeMount(Comp, {
|
|
props: {},
|
|
global: {
|
|
directives: {
|
|
[VPopover]: PopoverDirective,
|
|
},
|
|
},
|
|
})
|
|
|
|
describe('v-popover', () => {
|
|
afterEach(() => {
|
|
document.body.innerHTML = ''
|
|
})
|
|
test('should render correctly', async () => {
|
|
const wrapper = mount()
|
|
await nextTick()
|
|
|
|
expect(document.body.querySelector('.el-popover').innerHTML).toContain(
|
|
AXIOM
|
|
)
|
|
wrapper.unmount()
|
|
})
|
|
|
|
test.only('should show popover when reference is mounted', async () => {
|
|
const wrapper = mount()
|
|
await nextTick()
|
|
const refNode = '#reference-node'
|
|
expect(wrapper.find(refNode).exists()).toBe(true)
|
|
expect(
|
|
document.body.querySelector('.el-popover').getAttribute('style')
|
|
).toContain('display: none')
|
|
await wrapper.find(refNode).trigger('click', {
|
|
button: 0,
|
|
})
|
|
await nextTick()
|
|
await rAF()
|
|
expect(
|
|
document.body.querySelector('.el-popover').getAttribute('style')
|
|
).not.toContain('display: none')
|
|
wrapper.unmount()
|
|
})
|
|
})
|