2022-12-08 11:04:25 +00:00
|
|
|
import { config, mount } from '@vue/test-utils';
|
2022-12-08 14:13:16 +00:00
|
|
|
import InputText from 'primevue/inputtext';
|
2022-09-06 12:03:37 +00:00
|
|
|
import Inplace from './Inplace.vue';
|
2022-12-08 11:04:25 +00:00
|
|
|
|
|
|
|
config.global.mocks = {
|
|
|
|
$primevue: {
|
|
|
|
config: {
|
|
|
|
locale: {
|
|
|
|
aria: {
|
|
|
|
close: 'Close'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
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: `
|
|
|
|
<span class="pi pi-search" style="vertical-align: middle"></span>
|
|
|
|
<span style="margin-left:.5rem; vertical-align: middle">View Picture</span>
|
|
|
|
`,
|
2022-12-09 07:52:51 +00:00
|
|
|
content: `<img src="/demo/images/nature/nature1.jpg" />`
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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]);
|
|
|
|
});
|
|
|
|
|
2022-09-14 11:26:01 +00:00
|
|
|
it('closable inplace', async () => {
|
2022-09-06 12:03:37 +00:00
|
|
|
const wrapper = mount(Inplace, {
|
|
|
|
global: {
|
|
|
|
components: {
|
|
|
|
InputText
|
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
closable: true
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
display: `{{'Click to Edit'}}`,
|
|
|
|
content: `<InputText autoFocus />`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
2022-12-08 11:04:25 +00:00
|
|
|
|
|
|
|
it('should have custom close icon', async () => {
|
|
|
|
const wrapper = mount(Inplace, {
|
|
|
|
global: {
|
|
|
|
components: {
|
|
|
|
InputText
|
|
|
|
}
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
closable: true,
|
|
|
|
closeIcon: 'pi pi-discord'
|
|
|
|
},
|
|
|
|
slots: {
|
|
|
|
display: `{{'Click to Edit'}}`,
|
|
|
|
content: `<InputText autoFocus />`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
await wrapper.vm.open({});
|
|
|
|
|
|
|
|
expect(wrapper.find('.pi.pi-discord').exists()).toBe(true);
|
|
|
|
});
|
2022-09-14 11:26:01 +00:00
|
|
|
});
|