mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 11:33:04 +00:00
68067: Route menu data - menu ID
This commit is contained in:
@@ -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);
|
||||
|
@@ -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]];
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user