From 0aa0812540b0866bdc1d2b1b957becd2c8e6ce09 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:46 +0300 Subject: [PATCH] Create Inplace.spec.js --- src/components/inplace/Inplace.spec.js | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/components/inplace/Inplace.spec.js diff --git a/src/components/inplace/Inplace.spec.js b/src/components/inplace/Inplace.spec.js new file mode 100644 index 000000000..c79642ef1 --- /dev/null +++ b/src/components/inplace/Inplace.spec.js @@ -0,0 +1,67 @@ +import { mount } from '@vue/test-utils'; +import Inplace from './Inplace.vue'; +import InputText from '@/components/inputtext/InputText.vue'; + +describe('Inplace.vue', () => { + it('should exist', () => { + const wrapper = mount(Inplace); + + expect(wrapper.find('.p-inplace.p-component').exists()).toBe(true); + }); + + it('should slots display', () => { + const wrapper = mount(Inplace, { + global: { + components: { + InputText + } + }, + slots: { + display: ` + + View Picture + `, + content: `` + } + }); + + expect(wrapper.find('.p-inplace-display').exists()).toBe(true); + + wrapper.vm.open({}); + + expect(wrapper.emitted()['update:active'][0]).toEqual([true]); + + wrapper.vm.close({}); + + expect(wrapper.emitted()['update:active'][1]).toEqual([false]); + }); + + it('closable inplace', async() => { + const wrapper = mount(Inplace, { + global: { + components: { + InputText + } + }, + props: { + closable: true + }, + slots: { + display: `{{'Click to Edit'}}`, + content: `` + } + }); + + expect(wrapper.find('.p-inplace-closable').exists()).toBe(true); + expect(wrapper.find('.p-inplace-display').text()).toBe('Click to Edit'); + + await wrapper.vm.open({}); + + expect(wrapper.find('.p-inputtext').exists()).toBe(true); + expect(wrapper.find('.pi.pi-times').exists()).toBe(true); + + await wrapper.vm.close({}); + + expect(wrapper.find('.pi.pi-times').exists()).toBe(false); + }); +}); \ No newline at end of file