mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-14 17:31:02 +08:00
55348b30b6
* style: use prettier * style: just prettier format, no code changes * style: eslint fix object-shorthand, prefer-const * style: fix no-void * style: no-console
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { h, nextTick } from 'vue'
|
|
import { mount } from '@vue/test-utils'
|
|
import Tooltip from '../src/index'
|
|
|
|
import type { VNode } from 'vue'
|
|
|
|
const AXIOM = 'Rem is the best girl'
|
|
|
|
const _mount = (props: any = {}, content: string | VNode = '') =>
|
|
mount(Tooltip, {
|
|
slots: {
|
|
default: () => h('div', AXIOM),
|
|
content: () => content,
|
|
},
|
|
props,
|
|
attachTo: 'body',
|
|
})
|
|
|
|
const selector = '.el-popper'
|
|
describe('Tooltip.vue', () => {
|
|
beforeEach(() => {
|
|
document.body.innerHTML = ''
|
|
})
|
|
test('render test', () => {
|
|
const wrapper = _mount(undefined, AXIOM)
|
|
expect(wrapper.html()).toContain(AXIOM)
|
|
})
|
|
|
|
test('manual mode', async () => {
|
|
const wrapper = _mount(
|
|
{
|
|
manual: true,
|
|
modelValue: false,
|
|
},
|
|
AXIOM
|
|
)
|
|
// since VTU does not provide any functionality for testing teleported components
|
|
expect(document.querySelector(selector).getAttribute('style')).toContain(
|
|
'display: none'
|
|
)
|
|
|
|
await wrapper.setProps({
|
|
modelValue: true,
|
|
})
|
|
|
|
await nextTick()
|
|
expect(
|
|
document.querySelector(selector).getAttribute('style')
|
|
).not.toContain('display: none')
|
|
})
|
|
})
|