From da4a6d32cee2211f9cdce3da6284aedcc374ce1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Thu, 10 Mar 2022 13:40:32 +0300 Subject: [PATCH] Create Image.spec.js --- src/components/image/Image.spec.js | 47 ++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/components/image/Image.spec.js diff --git a/src/components/image/Image.spec.js b/src/components/image/Image.spec.js new file mode 100644 index 000000000..f4fc95b52 --- /dev/null +++ b/src/components/image/Image.spec.js @@ -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); + }); +}); \ No newline at end of file