test: refs #7058 requested changes
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2025-01-21 23:37:58 +01:00
parent 14ac4f7de6
commit 1ba24b46db
1 changed files with 35 additions and 28 deletions

View File

@ -108,7 +108,7 @@ vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
path: 'mockName/1', path: 'mockName/1',
name: 'Customer', name: 'Customer',
}); });
function mount(source) { function mount(source = 'main') {
vi.spyOn(axios, 'get').mockResolvedValue({ vi.spyOn(axios, 'get').mockResolvedValue({
data: [], data: [],
}); });
@ -186,7 +186,7 @@ describe('Leftmenu as card', () => {
}); });
describe('Leftmenu as main', () => { describe('Leftmenu as main', () => {
beforeEach(() => { beforeEach(() => {
vm = mount('main').vm; vm = mount().vm;
}); });
it('should initialize with default props', () => { it('should initialize with default props', () => {
@ -324,6 +324,39 @@ describe('normalize', () => {
}); });
describe('addChildren', () => { describe('addChildren', () => {
const module = 'testModule';
beforeEach(() => {
vm = mount().vm;
vi.clearAllMocks();
});
it('should add menu items to parent if matches are found', () => {
const parent = 'testParent';
const route = {
meta: {
menu: 'testMenu',
},
children: [{ name: 'child1' }, { name: 'child2' }],
};
vm.addChildren(module, route, parent);
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
});
it('should handle routes with no meta menu', () => {
const route = {
meta: {},
menus: {},
};
const parent = [];
vm.addChildren(module, route, parent);
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
});
it('should handle empty parent array', () => {
const parent = [];
const route = { const route = {
meta: { meta: {
menu: 'child11', menu: 'child11',
@ -343,32 +376,6 @@ describe('addChildren', () => {
}, },
], ],
}; };
beforeEach(() => {
vm = mount('main').vm;
vi.clearAllMocks();
});
it('should add menu items to parent if matches are found', () => {
const module = 'testModule';
const parent = [];
vm.addChildren(module, route, parent);
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
});
it('should handle routes with no meta menu', () => {
const module = 'testModule';
const parent = [];
vm.addChildren(module, route, parent);
expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
});
it('should handle empty parent array', () => {
const module = 'testModule';
const parent = [];
vm.addChildren(module, route, parent); vm.addChildren(module, route, parent);
expect(useNavigationStore().addMenuItem).toHaveBeenCalled(); expect(useNavigationStore().addMenuItem).toHaveBeenCalled();
}); });