mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
68067: JSDocs + menu-effects tests
This commit is contained in:
@@ -7,71 +7,25 @@ import { MenuComponent } from './menu.component';
|
||||
import { MenuServiceStub } from '../testing/menu-service.stub';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { MenuSection } from './menu.reducer';
|
||||
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||
import { Router } from '@angular/router';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { MenuID, MenuItemType } from './initial-menus-state';
|
||||
import { LinkMenuItemModel } from './menu-item/models/link.model';
|
||||
import { MenuID } from './initial-menus-state';
|
||||
|
||||
describe('MenuComponent', () => {
|
||||
let comp: MenuComponent;
|
||||
let fixture: ComponentFixture<MenuComponent>;
|
||||
let menuService: MenuService;
|
||||
let routeDataMenuSection: MenuSection;
|
||||
let routeDataMenuChildSection: MenuSection;
|
||||
let route: any;
|
||||
let router: any;
|
||||
|
||||
const mockMenuID = 'mock-menuID' as MenuID;
|
||||
|
||||
beforeEach(async(() => {
|
||||
routeDataMenuSection = {
|
||||
id: 'mockSection',
|
||||
active: false,
|
||||
visible: true,
|
||||
model: {
|
||||
type: MenuItemType.LINK,
|
||||
text: 'menu.section.mockSection',
|
||||
link: ''
|
||||
} as LinkMenuItemModel
|
||||
};
|
||||
routeDataMenuChildSection = {
|
||||
id: 'mockChildSection',
|
||||
parentID: 'mockSection',
|
||||
active: false,
|
||||
visible: true,
|
||||
model: {
|
||||
type: MenuItemType.LINK,
|
||||
text: 'menu.section.mockChildSection',
|
||||
link: ''
|
||||
} as LinkMenuItemModel
|
||||
};
|
||||
route = {
|
||||
root: {
|
||||
snapshot: {
|
||||
data: {
|
||||
menu: {
|
||||
[mockMenuID]: routeDataMenuSection
|
||||
}
|
||||
}
|
||||
},
|
||||
firstChild: {
|
||||
snapshot: {
|
||||
data: {
|
||||
menu: {
|
||||
[mockMenuID]: routeDataMenuChildSection
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, RouterTestingModule],
|
||||
declarations: [MenuComponent],
|
||||
providers: [
|
||||
{ provide: Injector, useValue: {} },
|
||||
{ provide: MenuService, useClass: MenuServiceStub },
|
||||
{ provide: ActivatedRoute, useValue: route }
|
||||
{ provide: MenuService, useClass: MenuServiceStub }
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).overrideComponent(MenuComponent, {
|
||||
@@ -90,30 +44,6 @@ describe('MenuComponent', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('ngOnInit', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(comp, 'resolveMenuSections').and.returnValue([]);
|
||||
});
|
||||
|
||||
it('should call resolveMenuSections on init', () => {
|
||||
router.events = observableOf(new NavigationEnd(0, '', ''));
|
||||
comp.ngOnInit();
|
||||
expect(comp.resolveMenuSections).toHaveBeenCalledWith(route.root);
|
||||
})
|
||||
});
|
||||
|
||||
describe('resolveMenuSections', () => {
|
||||
let result: MenuSection[];
|
||||
|
||||
beforeEach(() => {
|
||||
result = comp.resolveMenuSections(route.root);
|
||||
});
|
||||
|
||||
it('should return the current route\'s menu sections', () => {
|
||||
expect(result).toEqual([routeDataMenuSection, routeDataMenuChildSection])
|
||||
});
|
||||
});
|
||||
|
||||
describe('toggle', () => {
|
||||
beforeEach(() => {
|
||||
spyOn(menuService, 'toggleMenu');
|
||||
|
Reference in New Issue
Block a user