From 1ba24b46db235019bc339271b5f4e351397df25e Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 21 Jan 2025 23:37:58 +0100 Subject: [PATCH] test: refs #7058 requested changes --- src/components/__tests__/Leftmenu.spec.js | 63 +++++++++++++---------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/components/__tests__/Leftmenu.spec.js b/src/components/__tests__/Leftmenu.spec.js index c64aa50eb..a6089290f 100644 --- a/src/components/__tests__/Leftmenu.spec.js +++ b/src/components/__tests__/Leftmenu.spec.js @@ -108,7 +108,7 @@ vi.spyOn(vueRouter, 'useRoute').mockReturnValue({ path: 'mockName/1', name: 'Customer', }); -function mount(source) { +function mount(source = 'main') { vi.spyOn(axios, 'get').mockResolvedValue({ data: [], }); @@ -186,7 +186,7 @@ describe('Leftmenu as card', () => { }); describe('Leftmenu as main', () => { beforeEach(() => { - vm = mount('main').vm; + vm = mount().vm; }); it('should initialize with default props', () => { @@ -324,41 +324,31 @@ describe('normalize', () => { }); describe('addChildren', () => { - const route = { - meta: { - menu: 'child11', - }, - children: [ - { - name: 'child1', - meta: { - menuChildren: [ - { - name: 'CustomerCreditContracts', - title: 'creditContracts', - icon: 'vn:solunion', - }, - ], - }, - }, - ], - }; + const module = 'testModule'; beforeEach(() => { - vm = mount('main').vm; + vm = mount().vm; vi.clearAllMocks(); }); it('should add menu items to parent if matches are found', () => { - const module = 'testModule'; - const parent = []; - + 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 module = 'testModule'; + const route = { + meta: {}, + menus: {}, + }; + const parent = []; vm.addChildren(module, route, parent); @@ -366,9 +356,26 @@ describe('addChildren', () => { }); it('should handle empty parent array', () => { - const module = 'testModule'; const parent = []; - + const route = { + meta: { + menu: 'child11', + }, + children: [ + { + name: 'child1', + meta: { + menuChildren: [ + { + name: 'CustomerCreditContracts', + title: 'creditContracts', + icon: 'vn:solunion', + }, + ], + }, + }, + ], + }; vm.addChildren(module, route, parent); expect(useNavigationStore().addMenuItem).toHaveBeenCalled(); });