feat: refs #7058 expect parent
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2025-02-05 23:03:43 +01:00
parent 97dfeca20d
commit 698edfbe72
1 changed files with 10 additions and 5 deletions

View File

@ -107,6 +107,7 @@ describe('useNavigationStore', () => {
it('should add menu item correctly', () => { it('should add menu item correctly', () => {
const store = useNavigationStore(); const store = useNavigationStore();
const module = 'customer'; const module = 'customer';
const parent = [];
const route = { const route = {
name: 'customer', name: 'customer',
title: 'Customer', title: 'Customer',
@ -121,8 +122,8 @@ describe('useNavigationStore', () => {
}, },
}; };
const result = store.addMenuItem(module, route, []); const result = store.addMenuItem(module, route, parent);
expect(result).toEqual({ const expectedItem = {
children: [ children: [
{ {
icon: 'customer', icon: 'customer',
@ -134,15 +135,19 @@ describe('useNavigationStore', () => {
keyBinding: 'ctrl+shift+c', keyBinding: 'ctrl+shift+c',
name: 'customer', name: 'customer',
title: 'globals.pageTitles.Customer', title: 'globals.pageTitles.Customer',
}); };
expect(result).toEqual(expectedItem);
expect(parent.length).toBe(1);
expect(parent).toEqual([expectedItem]);
}); });
it('should not add menu item if condition is not met', () => { it('should not add menu item if condition is not met', () => {
const store = useNavigationStore(); const store = useNavigationStore();
const module = 'testModule'; const module = 'testModule';
const route = { meta: { hidden: true, menuchildren: {} } }; const route = { meta: { hidden: true, menuchildren: {} } };
const parent = [];
const result = store.addMenuItem(module, route, []); const result = store.addMenuItem(module, route, parent);
expect(result).toBeUndefined(); expect(result).toBeUndefined();
expect(parent.length).toBe(0);
}); });
}); });