mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 18:01:24 +08:00
ef92b6c11c
* Add overlay component; Dialog component almost done * feat(dialog): add use-lockscreen * feat(dialog): coding completed awaiting tests * feat(dialog): finish writing test cases * fix test failures * Address PR comments * fallback some changes
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { mount } from '@vue/test-utils'
|
|
import Overlay from '../src/index.vue'
|
|
|
|
const AXIOM = 'Rem is the best girl'
|
|
|
|
describe('Overlay.vue', () => {
|
|
test('render test', async () => {
|
|
const wrapper = mount(Overlay, {
|
|
slots: {
|
|
default: AXIOM,
|
|
},
|
|
})
|
|
expect(wrapper.text()).toEqual(AXIOM)
|
|
const testClass = 'test-class'
|
|
await wrapper.setProps({
|
|
overlayClass: testClass,
|
|
})
|
|
|
|
expect(wrapper.find(`.${testClass}`)).toBeTruthy()
|
|
})
|
|
|
|
test('should emit click event', async () => {
|
|
const wrapper = mount(Overlay, {
|
|
slots: {
|
|
default: AXIOM,
|
|
},
|
|
})
|
|
await wrapper.find('.el-overlay').trigger('click')
|
|
expect(wrapper.emitted()).toBeTruthy()
|
|
})
|
|
|
|
test('no mask', async () => {
|
|
const wrapper = mount(Overlay, {
|
|
slots: {
|
|
default: AXIOM,
|
|
},
|
|
})
|
|
const selector = '.el-overlay'
|
|
expect(wrapper.find(selector).exists()).toBe(true)
|
|
|
|
await wrapper.setProps({
|
|
mask: false,
|
|
})
|
|
expect(wrapper.find(selector).exists()).toBe(false)
|
|
})
|
|
})
|