primevue-mirror/components/image/Image.spec.js

53 lines
1.6 KiB
JavaScript
Raw Normal View History

2022-09-06 12:03:37 +00:00
import { mount } from '@vue/test-utils';
2022-12-08 11:04:25 +00:00
import PrimeVue from 'primevue/config';
2022-09-06 12:03:37 +00:00
import Image from './Image.vue';
describe('Image.vue', () => {
it('should exist', () => {
const wrapper = mount(Image, {
global: {
2022-12-08 11:04:25 +00:00
plugins: [PrimeVue],
2022-09-06 12:03:37 +00:00
stubs: {
teleport: true
}
},
props: {
src: 'images/galleria/galleria1.jpg'
2022-09-06 12:03:37 +00:00
}
});
expect(wrapper.find('.p-image.p-component').exists()).toBe(true);
expect(wrapper.find('.p-image.p-component img').attributes().src).toBe('images/galleria/galleria1.jpg');
2022-09-06 12:03:37 +00:00
});
2022-09-14 11:26:01 +00:00
it('should preview', async () => {
2022-09-06 12:03:37 +00:00
const wrapper = mount(Image, {
global: {
2022-12-08 11:04:25 +00:00
plugins: [PrimeVue],
2022-09-06 12:03:37 +00:00
stubs: {
teleport: true
}
},
props: {
src: 'images/galleria/galleria1.jpg',
2022-09-06 12:03:37 +00:00
preview: true
}
});
expect(wrapper.find('.p-image-preview-container').exists()).toBe(true);
expect(wrapper.find('.p-image-preview-indicator').exists()).toBe(true);
expect(wrapper.find('.p-image-mask').exists()).toBe(false);
2022-09-14 11:26:01 +00:00
await wrapper.setData({ maskVisible: true });
2022-09-06 12:03:37 +00:00
expect(wrapper.find('.p-image-mask').exists()).toBe(true);
expect(wrapper.find('.p-image-toolbar').exists()).toBe(true);
2022-09-14 11:26:01 +00:00
await wrapper.setData({ maskVisible: false });
2022-09-06 12:03:37 +00:00
2022-12-08 11:04:25 +00:00
setTimeout(() => {
expect(wrapper.find('.p-image-mask').exists()).toBe(false);
}, 25);
2022-09-06 12:03:37 +00:00
});
2022-09-14 11:26:01 +00:00
});