diff --git a/src/app/shared/menu/menu.component.spec.ts b/src/app/shared/menu/menu.component.spec.ts index 3524dfaae3..901f072dd7 100644 --- a/src/app/shared/menu/menu.component.spec.ts +++ b/src/app/shared/menu/menu.component.spec.ts @@ -9,7 +9,7 @@ import { of as observableOf } from 'rxjs'; import { MenuSection } from './menu.reducer'; import { ActivatedRoute, NavigationEnd, Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; -import { MenuItemType } from './initial-menus-state'; +import { MenuID, MenuItemType } from './initial-menus-state'; import { LinkMenuItemModel } from './menu-item/models/link.model'; describe('MenuComponent', () => { @@ -21,6 +21,8 @@ describe('MenuComponent', () => { let route: any; let router: any; + const mockMenuID = 'mock-menuID' as MenuID; + beforeEach(async(() => { routeDataMenuSection = { id: 'mockSection', @@ -47,13 +49,17 @@ describe('MenuComponent', () => { root: { snapshot: { data: { - menu: routeDataMenuSection + menu: { + [mockMenuID]: routeDataMenuSection + } } }, firstChild: { snapshot: { data: { - menu: routeDataMenuChildSection + menu: { + [mockMenuID]: routeDataMenuChildSection + } } } } @@ -76,6 +82,7 @@ describe('MenuComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(MenuComponent); comp = fixture.componentInstance; // SearchPageComponent test instance + comp.menuID = mockMenuID; menuService = (comp as any).menuService; router = TestBed.get(Router); spyOn(comp as any, 'getSectionDataInjector').and.returnValue(MenuSection); diff --git a/src/app/shared/menu/menu.component.ts b/src/app/shared/menu/menu.component.ts index cf9c2752dd..074d0f1e95 100644 --- a/src/app/shared/menu/menu.component.ts +++ b/src/app/shared/menu/menu.component.ts @@ -125,11 +125,11 @@ export class MenuComponent implements OnInit, OnDestroy { const data = route.snapshot.data; const last: boolean = hasNoValue(route.firstChild); - if (hasValue(data) && hasValue(data.menu)) { + if (hasValue(data) && hasValue(data.menu) && hasValue(data.menu[this.menuID])) { if (!last) { - return [...data.menu, ...this.resolveMenuSections(route.firstChild)] + return [...data.menu[this.menuID], ...this.resolveMenuSections(route.firstChild)] } else { - return [...data.menu]; + return [...data.menu[this.menuID]]; } }