diff --git a/src/components/VnTable/__tests__/LeftMenu.spec.js b/src/components/VnTable/__tests__/LeftMenu.spec.js index 09d299647..0d0d85153 100644 --- a/src/components/VnTable/__tests__/LeftMenu.spec.js +++ b/src/components/VnTable/__tests__/LeftMenu.spec.js @@ -1,6 +1,7 @@ import { describe, expect, it, beforeAll, beforeEach, vi } from 'vitest'; import { createWrapper } from 'app/test/vitest/helper'; import LeftMenu from 'src/components/LeftMenu.vue'; +import { useNavigationStore } from 'src/stores/useNavigationStore'; describe('LeftMenu', () => { let wrapper; @@ -19,6 +20,10 @@ describe('LeftMenu', () => { useNavigationStore: vi.fn(() => ({ items: [], expansionItemElements: {}, + addMenuItem: vi.fn(), + getModules: vi.fn(() => ({ + value: [], + })), })), }; }); @@ -52,4 +57,40 @@ describe('LeftMenu', () => { new Map([['Item 2', { name: 'Item 2', isPinned: true }]]) ); }); + + it('should find matches in routes', () => { + const search = 'child1'; + const item = { + children: [ + { name: 'child1', children: [] }, + { name: 'child2', children: [] }, + ], + }; + const matches = vm.findMatches(search, item); + expect(matches).toEqual([{ name: 'child1', children: [] }]); + }); + + it('should add children to navigation', () => { + const module = 'module1'; + const route = { + meta: { menu: 'child1' }, + children: [ + { name: 'child1', children: [] }, + { name: 'child2', children: [] }, + ], + }; + const parent = 'parent1'; + vm.addChildren(module, route, parent); + expect(useNavigationStore().addMenuItem).toHaveBeenCalledWith( + module, + { name: 'child1', children: [] }, + parent + ); + }); + + it('should get routes for main source', () => { + vm.props.source = 'main'; + vm.getRoutes(); + expect(useNavigationStore().getModules).toHaveBeenCalled(); + }); });