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