2020-10-16 11:14:45 +08:00
|
|
|
import { h } from 'vue'
|
|
|
|
import { mount } from '@vue/test-utils'
|
2021-09-19 18:21:23 +08:00
|
|
|
import ElPopconfirm from '../src/popconfirm.vue'
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2020-10-16 11:14:45 +08:00
|
|
|
const selector = '.el-popper'
|
2021-09-04 19:29:28 +08:00
|
|
|
const _mount = (props: any = {}) =>
|
|
|
|
mount(ElPopconfirm, {
|
|
|
|
props,
|
|
|
|
slots: {
|
|
|
|
reference: () =>
|
|
|
|
h('div', {
|
|
|
|
class: 'reference',
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
attachTo: 'body',
|
|
|
|
})
|
2020-10-16 11:14:45 +08:00
|
|
|
|
|
|
|
describe('Popconfirm.vue', () => {
|
|
|
|
test('render test', async () => {
|
|
|
|
const wrapper = _mount()
|
|
|
|
const trigger = wrapper.find('.reference')
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
expect(document.querySelector(selector).getAttribute('style')).toContain(
|
|
|
|
'display: none'
|
|
|
|
)
|
2020-10-16 11:14:45 +08:00
|
|
|
|
|
|
|
await trigger.trigger('click')
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
expect(
|
|
|
|
document.querySelector(selector).getAttribute('style')
|
|
|
|
).not.toContain('display: none')
|
2020-10-16 11:14:45 +08:00
|
|
|
})
|
|
|
|
})
|