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', () => {
const store = useNavigationStore();
const module = 'customer';
const parent = [];
const route = {
name: 'customer',
title: 'Customer',
@ -121,8 +122,8 @@ describe('useNavigationStore', () => {
},
};
const result = store.addMenuItem(module, route, []);
expect(result).toEqual({
const result = store.addMenuItem(module, route, parent);
const expectedItem = {
children: [
{
icon: 'customer',
@ -134,15 +135,19 @@ describe('useNavigationStore', () => {
keyBinding: 'ctrl+shift+c',
name: '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', () => {
const store = useNavigationStore();
const module = 'testModule';
const route = { meta: { hidden: true, menuchildren: {} } };
const result = store.addMenuItem(module, route, []);
const parent = [];
const result = store.addMenuItem(module, route, parent);
expect(result).toBeUndefined();
expect(parent.length).toBe(0);
});
});