Create OverlayPanel.spec.js

pull/2337/head
Tuğçe Küçükoğlu 2022-03-18 16:11:07 +03:00
parent f7d9a40adb
commit 57dc58e326
1 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,48 @@
import { mount } from '@vue/test-utils';
import PrimeVue from '@/components/config/PrimeVue';
import OverlayPanel from './OverlayPanel.vue';
describe('OverlayPanel.vue', () => {
let wrapper;
beforeEach(async () => {
wrapper = mount(OverlayPanel, {
global: {
plugins: [PrimeVue],
stubs: {
teleport: true
}
},
props: {
showCloseIcon: true,
ariaCloseLabel: 'exit'
},
slots: {
default: 'PrimeVue'
}
});
await wrapper.vm.toggle({}, {});
});
it('should exist', () => {
expect(wrapper.find('.p-overlaypanel.p-component').exists()).toBe(true);
expect(wrapper.find('.p-overlaypanel-content').exists()).toBe(true);
expect(wrapper.find('.p-overlaypanel-content').text()).toBe('PrimeVue');
expect(wrapper.find('.p-overlaypanel-close').exists()).toBe(true);
expect(wrapper.find('.p-overlaypanel-close').attributes()['aria-label']).toBe('exit');
console.log(wrapper.html())
});
it('should toggle itself', async () => {
await wrapper.vm.toggle({}, {});
expect(wrapper.find('.p-overlaypanel.p-component').exists()).toBe(false);
});
it('should close icon work', async () => {
await wrapper.vm.hide();
expect(wrapper.vm.visible).toBe(false);
});
});