diff --git a/web/src/app/shared/components/nav-bar/nav-bar.component.spec.ts b/web/src/app/shared/components/nav-bar/nav-bar.component.spec.ts index acfb4d5cf..839ff6dee 100644 --- a/web/src/app/shared/components/nav-bar/nav-bar.component.spec.ts +++ b/web/src/app/shared/components/nav-bar/nav-bar.component.spec.ts @@ -1,4 +1,4 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { Component, DebugElement } from '@angular/core'; import { NavBarComponent } from './nav-bar.component'; import { SelectedRouteService } from '../../services/selected-route/selected-route'; @@ -28,16 +28,18 @@ describe('NavBarComponent', () => { let debugElement: DebugElement; let route = ''; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [NavBarComponent, SvgIconStub], - imports: [MatIconModule, HttpClientTestingModule, MatToolbarModule], - providers: [ - { provide: SidenavService, useValue: SidenavServiceSpy }, - { provide: SelectedRouteService, useValue: SelectedRouteServiceSpy } - ] - }).compileComponents(); - })); + beforeEach( + waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [NavBarComponent, SvgIconStub], + imports: [MatIconModule, HttpClientTestingModule, MatToolbarModule], + providers: [ + { provide: SidenavService, useValue: SidenavServiceSpy }, + { provide: SelectedRouteService, useValue: SelectedRouteServiceSpy } + ] + }).compileComponents(); + }) + ); beforeEach(() => { fixture = TestBed.createComponent(NavBarComponent); @@ -57,6 +59,48 @@ describe('NavBarComponent', () => { expect(component.title).toBe('Workbaskets'); }); + it('should set title to classification if classification ist selected', () => { + route = 'classifications'; + fixture.detectChanges(); + component.setTitle(route); + expect(component.title).toBe('Classifications'); + }); + + it('should set title to monitor if monitor ist selected', () => { + route = 'monitor'; + fixture.detectChanges(); + component.setTitle(route); + expect(component.title).toBe('Monitor'); + }); + + it('should set title to workplace if workplace ist selected', () => { + route = 'workplace'; + fixture.detectChanges(); + component.setTitle(route); + expect(component.title).toBe('Workplace'); + }); + + it('should set title to access-items if access-items ist selected', () => { + route = 'access-items'; + fixture.detectChanges(); + component.setTitle(route); + expect(component.title).toBe('Access items'); + }); + + it('should set title to history if history ist selected', () => { + route = 'history'; + fixture.detectChanges(); + component.setTitle(route); + expect(component.title).toBe('History'); + }); + + it('should set title to settings if settings ist selected', () => { + route = 'settings'; + fixture.detectChanges(); + component.setTitle(route); + expect(component.title).toBe('Settings'); + }); + it('should toggle sidenav when button clicked', () => { fixture.detectChanges(); expect(component.toggle).toBe(false); diff --git a/web/src/app/shared/components/nav-bar/nav-bar.component.ts b/web/src/app/shared/components/nav-bar/nav-bar.component.ts index 024f49dd2..f18ec4174 100644 --- a/web/src/app/shared/components/nav-bar/nav-bar.component.ts +++ b/web/src/app/shared/components/nav-bar/nav-bar.component.ts @@ -40,19 +40,19 @@ export class NavBarComponent implements OnInit { } setTitle(value: string = '') { - if (value.indexOf('workbaskets') === 0) { + if (value.includes('workbaskets')) { this.title = this.titleWorkbaskets; - } else if (value.indexOf('classifications') === 0) { + } else if (value.includes('classifications')) { this.title = this.titleClassifications; - } else if (value.indexOf('monitor') === 0) { + } else if (value.includes('monitor')) { this.title = this.titleMonitor; - } else if (value.indexOf('workplace') === 0) { + } else if (value.includes('workplace')) { this.title = this.titleWorkplace; - } else if (value.indexOf('access-items') === 0) { + } else if (value.includes('access-items')) { this.title = this.titleAccessItems; - } else if (value.indexOf('history') === 0) { + } else if (value.includes('history')) { this.title = this.titleHistory; - } else if (value.indexOf('settings') === 0) { + } else if (value.includes('settings')) { this.title = this.titleSettings; } } diff --git a/web/src/app/shared/services/access-ids/access-ids.service.spec.ts b/web/src/app/shared/services/access-ids/access-ids.service.spec.ts index 04a1aa72f..cc7b2e845 100644 --- a/web/src/app/shared/services/access-ids/access-ids.service.spec.ts +++ b/web/src/app/shared/services/access-ids/access-ids.service.spec.ts @@ -1,8 +1,7 @@ -import { TestBed, inject } from '@angular/core/testing'; +import { inject, TestBed } from '@angular/core/testing'; import { HttpClientModule } from '@angular/common/http'; import { AccessIdsService } from './access-ids.service'; -import { SelectedRouteService } from '../selected-route/selected-route'; import { StartupService } from '../startup/startup.service'; import { TaskanaEngineService } from '../taskana-engine/taskana-engine.service'; import { WindowRefService } from '../window/window.service'; diff --git a/web/src/app/shared/services/selected-route/selected-route.ts b/web/src/app/shared/services/selected-route/selected-route.ts index 7a3409a3c..49bc86b87 100644 --- a/web/src/app/shared/services/selected-route/selected-route.ts +++ b/web/src/app/shared/services/selected-route/selected-route.ts @@ -1,18 +1,19 @@ -import { Injectable, OnInit } from '@angular/core'; -import { Subject, Observable } from 'rxjs'; -import { Router, ActivatedRoute, NavigationStart } from '@angular/router'; +import { Injectable } from '@angular/core'; +import { Observable, Subject } from 'rxjs'; +import { Router } from '@angular/router'; @Injectable() export class SelectedRouteService { public selectedRouteTriggered = new Subject(); private detailRoutes: Array = [ - 'workbaskets', - 'classifications', - 'monitor', 'workplace', - 'access-items-management', - 'history' + 'administration/workbaskets', + 'administration/classifications', + 'monitor', + 'administration/access-items-management', + 'history', + 'settings' ]; constructor(private router: Router) {} @@ -33,6 +34,6 @@ export class SelectedRouteService { } private checkUrl(url: string): string { - return this.detailRoutes.find((routeDetail) => url.indexOf(routeDetail) !== -1) || ''; + return this.detailRoutes.find((routeDetail) => url.includes(routeDetail)) || ''; } }