element-plus/packages/components/popconfirm/__test__/popconfirm.spec.ts
jeremywu df57ddfe39
fix(components): [el-dropdown] cannot be closed by clicking outside (#5287)
- 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
2022-01-11 10:24:48 +08:00

52 lines
1.1 KiB
TypeScript

import { h, nextTick } from 'vue'
import { mount } from '@vue/test-utils'
import { rAF } from '@element-plus/test-utils/tick'
import ElPopconfirm from '../src/popconfirm.vue'
const AXIOM = 'rem is the best girl'
const selector = '.el-popper'
const _mount = (props: any = {}) =>
mount(ElPopconfirm, {
props: {
...props,
},
slots: {
reference: () =>
h(
'div',
{
class: 'reference',
},
[AXIOM]
),
},
attachTo: 'body',
})
describe('Popconfirm.vue', () => {
afterEach(() => {
document.body.innerHTML = ''
})
test('render test', async () => {
const wrapper = _mount()
await nextTick()
const trigger = wrapper.find('.reference')
expect(document.querySelector(selector)!.getAttribute('style')).toContain(
'display: none'
)
await trigger.trigger('click', {
button: 0,
})
await nextTick()
await rAF()
expect(
document.querySelector(selector)!.getAttribute('style')
).not.toContain('display: none')
})
})