- fix InputNumber.spec.js, InputSwitch.spec.js, Listbox.spec.js, MegaMenu.spec.js

pull/6170/head
uros 2024-08-01 20:55:57 +02:00
parent 09aee632b3
commit 7c308fe41b
4 changed files with 19 additions and 19 deletions

View File

@ -44,7 +44,7 @@ describe('InputNumber.vue', () => {
it('is keypress called when pressed a number', async () => {
wrapper.find('input.p-inputnumber-input').element.setSelectionRange(2, 2);
await wrapper.vm.onInputKeyPress({ which: 49, preventDefault: () => {} });
await wrapper.vm.onInputKeyPress({ key: '1', preventDefault: () => {} });
expect(wrapper.emitted().input[0][0].value).toBe(11);
});
@ -52,7 +52,7 @@ describe('InputNumber.vue', () => {
it('is keypress called when pressed minus', async () => {
wrapper.find('input.p-inputnumber-input').element.setSelectionRange(0, 0);
await wrapper.vm.onInputKeyPress({ keyCode: 45, preventDefault: () => {} });
await wrapper.vm.onInputKeyPress({ key: '-', preventDefault: () => {} });
expect(wrapper.emitted().input[0][0].value).toBe(-1);
});

View File

@ -5,8 +5,8 @@ describe('InputSwitch.vue', () => {
it('should exist', async () => {
const wrapper = mount(InputSwitch);
expect(wrapper.find('.p-inputswitch.p-component').exists()).toBe(true);
expect(wrapper.find('.p-inputswitch-slider').exists()).toBe(true);
expect(wrapper.find('.p-toggleswitch.p-component').exists()).toBe(true);
expect(wrapper.find('.p-toggleswitch-slider').exists()).toBe(true);
await wrapper.vm.onChange({});
@ -15,6 +15,6 @@ describe('InputSwitch.vue', () => {
await wrapper.setProps({ modelValue: true });
expect(wrapper.vm.checked).toBe(true);
expect(wrapper.find('.p-inputswitch').classes()).toContain('p-highlight');
expect(wrapper.find('.p-toggleswitch').classes()).toContain('p-toggleswitch-checked');
});
});

View File

@ -22,8 +22,8 @@ describe('Listbox.vue', () => {
it('should exist', () => {
expect(wrapper.find('.p-listbox.p-component').exists()).toBe(true);
expect(wrapper.findAll('li.p-listbox-item').length).toBe(5);
expect(wrapper.findAll('li.p-listbox-item')[0].attributes()['aria-label']).toBe('New York');
expect(wrapper.findAll('li.p-listbox-option').length).toBe(5);
expect(wrapper.findAll('li.p-listbox-option')[0].attributes()['aria-label']).toBe('New York');
});
it('should select a list item', async () => {
@ -33,7 +33,7 @@ describe('Listbox.vue', () => {
await wrapper.setProps({ modelValue: wrapper.vm.options[0] });
expect(wrapper.findAll('li.p-listbox-item')[0].classes()).toContain('p-highlight');
expect(wrapper.findAll('li.p-listbox-option')[0].classes()).toContain('p-listbox-option-selected');
});
describe('filter', () => {
@ -43,7 +43,7 @@ describe('Listbox.vue', () => {
filterIcon: 'pi pi-discord'
});
const icon = wrapper.find('.p-listbox-filter-icon');
const icon = wrapper.find('.p-inputicon [data-pc-section="filtericon"]');
expect(icon.classes()).toContain('pi-discord');
});

View File

@ -60,28 +60,28 @@ describe('MegaMenu.vue', () => {
expect(wrapper.find('.p-megamenu.p-component').exists()).toBe(true);
expect(wrapper.find('.p-megamenu-root-list').exists()).toBe(true);
expect(wrapper.findAll('ul.p-megamenu-submenu').length).toBe(5);
expect(wrapper.findAll('li.p-menuitem').length).toBe(12);
expect(wrapper.findAll('li.p-menuitem')[0].findAll('span.p-menuitem-text')[0].text()).toBe('Videos');
expect(wrapper.findAll('li.p-megamenu-submenu-header')[0].text()).toBe('Video 1');
expect(wrapper.findAll('li.p-menuitem')[1].findAll('span.p-menuitem-text')[0].text()).toBe('Video 1.1');
expect(wrapper.findAll('li.p-megamenu-item').length).toBe(12);
expect(wrapper.findAll('li.p-megamenu-item')[0].findAll('span.p-megamenu-item-label')[0].text()).toBe('Videos');
expect(wrapper.findAll('li.p-megamenu-submenu-label')[0].text()).toBe('Video 1');
expect(wrapper.findAll('li.p-megamenu-item')[1].findAll('span.p-megamenu-item-label')[0].text()).toBe('Video 1.1');
});
it('should select item', async () => {
const firstItem = wrapper.findAll('li.p-menuitem')[0];
const firstItem = wrapper.findAll('li.p-megamenu-item')[0];
await firstItem.find('.p-menuitem-content').trigger('click');
await firstItem.find('.p-megamenu-item-content').trigger('click');
expect(firstItem.classes()).toContain('p-menuitem-active');
expect(firstItem.classes()).toContain('p-megamenu-item-active');
});
it('should deselect item', async () => {
const firstItem = wrapper.findAll('li.p-menuitem')[0];
const firstItemContent = firstItem.find('.p-menuitem-content');
const firstItem = wrapper.findAll('li.p-megamenu-item')[0];
const firstItemContent = firstItem.find('.p-megamenu-item-content');
await firstItemContent.trigger('click');
await firstItemContent.trigger('click');
expect(firstItem.classes()).not.toContain('p-menuitem-active');
expect(firstItem.classes()).not.toContain('p-megamenu-item-active');
});
it('should orientation work', async () => {