- fix BlockUI.spec.js, Carousel.spec.js, CascadeSelect.spec.js

pull/6170/head
uros 2024-08-01 23:22:05 +02:00
parent 7094c05583
commit b94a4b23a0
3 changed files with 20 additions and 11 deletions

View File

@ -1,4 +1,5 @@
import { mount } from '@vue/test-utils';
import PrimeVue from 'primevue/config';
import { beforeEach, expect } from 'vitest';
import BlockUI from './BlockUI.vue';
@ -6,7 +7,15 @@ let wrapper = null;
describe('BlockUI.vue', () => {
beforeEach(() => {
wrapper = mount(BlockUI);
wrapper = mount(BlockUI, {
attachTo: document.body,
global: {
plugins: [PrimeVue],
stubs: {
teleport: true
}
}
});
});
afterEach(() => {

View File

@ -81,7 +81,7 @@ describe('Carousel.vue', () => {
expect(firstItem.classes()).toContain('p-carousel-item-active');
const nextBtn = wrapper.find('.p-carousel-next');
const nextBtn = wrapper.find('.p-carousel-next-button');
await nextBtn.trigger('click');

View File

@ -106,20 +106,20 @@ describe('CascadeSelect.vue', () => {
await wrapper.trigger('click');
expect(wrapper.find('.p-cascadeselect-panel.p-cascadeselect-items').exists()).toBe(true);
expect(wrapper.findAll('.p-cascadeselect-item').length).toBe(3);
expect(wrapper.findAll('.p-cascadeselect-item-text')[0].text()).toBe('Australia');
expect(wrapper.find('.p-cascadeselect-list').exists()).toBe(true);
expect(wrapper.findAll('.p-cascadeselect-option').length).toBe(3);
expect(wrapper.findAll('.p-cascadeselect-option-text')[0].text()).toBe('Australia');
const firstGroup = wrapper.findAll('.p-cascadeselect-item-content')[0];
const firstGroup = wrapper.findAll('.p-cascadeselect-option-content')[0];
await firstGroup.trigger('click');
expect(wrapper.find('.p-cascadeselect-panel.p-cascadeselect-sublist').exists()).toBe(true);
expect(wrapper.find('.p-cascadeselect-list .p-cascadeselect-option-list').exists()).toBe(true);
const sublist = wrapper.find('.p-cascadeselect-panel.p-cascadeselect-sublist');
const sublist = wrapper.find('.p-cascadeselect-list .p-cascadeselect-option-list');
expect(sublist.findAll('.p-cascadeselect-item.p-cascadeselect-item-group').length).toBe(2);
expect(sublist.findAll('.p-cascadeselect-item-text')[0].text()).toBe('New South Wales');
expect(sublist.findAll('.p-cascadeselect-option').length).toBe(2);
expect(sublist.findAll('.p-cascadeselect-option-text')[0].text()).toBe('New South Wales');
});
it('should accept custom icons', async () => {
@ -130,7 +130,7 @@ describe('CascadeSelect.vue', () => {
await nextTick();
expect(wrapper.find('.p-cascadeselect-trigger-icon').classes()).toContain('pi-discord');
expect(wrapper.find('.p-cascadeselect-dropdown-icon').classes()).toContain('pi-discord');
await wrapper.trigger('click');