Create Image.spec.js

pull/2305/head
Tuğçe Küçükoğlu 2022-03-10 13:40:32 +03:00 committed by Tuğçe Küçükoğlu
parent 7d79262106
commit da4a6d32ce
1 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,47 @@
import { mount } from '@vue/test-utils';
import Image from './Image.vue';
describe('Image.vue', () => {
it('should exist', () => {
const wrapper = mount(Image, {
global: {
stubs: {
teleport: true
}
},
props: {
src: 'demo/images/galleria/galleria1.jpg'
}
});
expect(wrapper.find('.p-image.p-component').exists()).toBe(true);
expect(wrapper.find('.p-image.p-component img').attributes().src).toBe('demo/images/galleria/galleria1.jpg');
});
it('should preview', async() => {
const wrapper = mount(Image, {
global: {
stubs: {
teleport: true
}
},
props: {
src: 'demo/images/galleria/galleria1.jpg',
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);
await wrapper.setData({ maskVisible: true});
expect(wrapper.find('.p-image-mask').exists()).toBe(true);
expect(wrapper.find('.p-image-toolbar').exists()).toBe(true);
await wrapper.setData({ maskVisible: false});
expect(wrapper.find('.p-image-mask').exists()).toBe(false);
});
});