mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-04 20:27:44 +08:00
refactor(components): [image-viewer] use JSX in Unit test (#9717)
This commit is contained in:
parent
3b264a106f
commit
0296ba2fb7
@ -1,16 +1,9 @@
|
||||
import { nextTick } from 'vue'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import { IMAGE_SUCCESS } from '@element-plus/test-utils/mock'
|
||||
import makeMount from '@element-plus/test-utils/make-mount'
|
||||
import ImageViewer from '../src/image-viewer.vue'
|
||||
|
||||
const mount = makeMount(ImageViewer, {
|
||||
props: {
|
||||
urlList: [IMAGE_SUCCESS],
|
||||
},
|
||||
})
|
||||
|
||||
async function doubleWait() {
|
||||
await nextTick()
|
||||
await nextTick()
|
||||
@ -18,7 +11,8 @@ async function doubleWait() {
|
||||
|
||||
describe('<image-viewer />', () => {
|
||||
test('big image preview', async () => {
|
||||
const wrapper = mount()
|
||||
const wrapper = mount(<ImageViewer urlList={[IMAGE_SUCCESS]} />)
|
||||
|
||||
await doubleWait()
|
||||
const viewer = wrapper.find('.el-image-viewer__wrapper')
|
||||
expect(viewer.exists()).toBe(true)
|
||||
@ -28,7 +22,7 @@ describe('<image-viewer />', () => {
|
||||
})
|
||||
|
||||
test('image preview hide-click-on-modal', async () => {
|
||||
const wrapper = mount()
|
||||
const wrapper = mount(<ImageViewer urlList={[IMAGE_SUCCESS]} />)
|
||||
|
||||
await doubleWait()
|
||||
const viewer = wrapper.find('.el-image-viewer__wrapper')
|
||||
@ -46,11 +40,9 @@ describe('<image-viewer />', () => {
|
||||
})
|
||||
|
||||
test('manually switch image', async () => {
|
||||
const wrapper = mount({
|
||||
props: {
|
||||
urlList: [IMAGE_SUCCESS, IMAGE_SUCCESS],
|
||||
},
|
||||
})
|
||||
const wrapper = mount(
|
||||
<ImageViewer urlList={[IMAGE_SUCCESS, IMAGE_SUCCESS]} />
|
||||
)
|
||||
|
||||
await doubleWait()
|
||||
const viewer = wrapper.find('.el-image-viewer__wrapper')
|
Loading…
Reference in New Issue
Block a user