Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Oct 19, 2022
1 parent 6903ce6 commit 7825c89
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/components/megamenu/MegaMenu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ describe('MegaMenu.vue', () => {
it('should select item', async () => {
const firstItem = wrapper.findAll('li.p-menuitem')[0];

await wrapper.vm.onCategoryClick({}, wrapper.vm.model[0]);
await firstItem.trigger('click');

expect(firstItem.classes()).toContain('p-menuitem-active');
});

it('should deselect item', async () => {
const firstItem = wrapper.findAll('li.p-menuitem')[0];

await wrapper.vm.onCategoryClick({}, wrapper.vm.model[0].items[0][0].items[0]);
await firstItem.trigger('click');
await firstItem.trigger('click');

expect(firstItem.classes()).not.toContain('p-menuitem-active');
});
Expand Down
16 changes: 11 additions & 5 deletions src/components/megamenu/MegaMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,16 @@ export default {
const { originalEvent, processedItem } = event;
const grouped = this.isProccessedItemGroup(processedItem);
const root = ObjectUtils.isEmpty(processedItem.parent);
const selected = this.isSelected(processedItem);
grouped ? this.onItemChange(event) : this.hide(originalEvent, !root);
if (root && selected) {
this.focusedItemInfo = { index: processedItem.index, key: processedItem.key };
this.activeItem = null;
DomHandler.focus(this.menubar);
} else {
grouped ? this.onItemChange(event) : this.hide(originalEvent, !root);
}
},
onItemMouseEnter(event) {
if (this.dirty) {
Expand Down Expand Up @@ -286,7 +294,7 @@ export default {
}
},
onArrowLeftKey(event) {
const processedItem = this.findVisibleItem(this.focusedItemInfo.index);
const processedItem = (ObjectUtils.isNotEmpty(this.activeItem) && this.activeItem.key === this.focusedItemInfo.key ? this.activeItem : null) || this.findVisibleItem(this.focusedItemInfo.index);
const grouped = this.isProccessedItemGroup(processedItem);
if (grouped) {
Expand Down Expand Up @@ -546,9 +554,7 @@ export default {
'p-megamenu p-component',
{
'p-megamenu-horizontal': this.horizontal,
'p-megamenu-vertical': this.vertical,
'p-input-filled': this.$primevue.config.inputStyle === 'filled',
'p-ripple-disabled': this.$primevue.config.ripple === false
'p-megamenu-vertical': this.vertical
}
];
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/panelmenu/PanelMenu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('PanelMenu', () => {

await wrapper.vm.onHeaderClick({}, wrapper.vm.model[0]);

expect(wrapper.find('.p-panelmenu-header-action > .p-panelmenu-icon').classes()).toContain('pi-chevron-down');
expect(wrapper.find('.p-panelmenu-header-action > .p-submenu-icon').classes()).toContain('pi-chevron-down');
expect(wrapper.findAll('.p-toggleable-content')[0].attributes().style).toBe(undefined);
});

Expand Down

0 comments on commit 7825c89

Please sign in to comment.