mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-21 02:50:11 +08:00
0636e1e240
* style: add import lint * chore: apply eslint rules * chore: add stricter lint * chore: lint all files * auto fix * manually fix * restore build-indices.ts
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { nextTick } from 'vue'
|
|
|
|
import { IMAGE_SUCCESS } from '@element-plus/test-utils/mock'
|
|
import makeMount from '@element-plus/test-utils/make-mount'
|
|
import ImageViewer from '../src/index.vue'
|
|
|
|
const mount = makeMount(ImageViewer, {
|
|
props: {
|
|
src: IMAGE_SUCCESS,
|
|
urlList: [IMAGE_SUCCESS],
|
|
},
|
|
})
|
|
|
|
async function doubleWait() {
|
|
await nextTick()
|
|
await nextTick()
|
|
}
|
|
|
|
describe('<image-viewer />', () => {
|
|
test('big image preview', async () => {
|
|
const wrapper = mount()
|
|
await doubleWait()
|
|
const viewer = wrapper.find('.el-image-viewer__wrapper')
|
|
expect(viewer.exists()).toBe(true)
|
|
await wrapper.find('.el-image-viewer__close').trigger('click')
|
|
expect(wrapper.emitted('close')).toEqual([[]])
|
|
})
|
|
|
|
test('image preview hide-click-on-modal', async () => {
|
|
const wrapper = mount()
|
|
|
|
await doubleWait()
|
|
const viewer = wrapper.find('.el-image-viewer__wrapper')
|
|
expect(viewer.exists()).toBe(true)
|
|
await wrapper.find('.el-image-viewer__mask').trigger('click')
|
|
expect(wrapper.emitted('close')).toBeUndefined()
|
|
|
|
await wrapper.setProps({
|
|
hideOnClickModal: true,
|
|
})
|
|
|
|
await wrapper.find('.el-image-viewer__mask').trigger('click')
|
|
expect(wrapper.emitted('close')).toBeDefined()
|
|
})
|
|
})
|