TSK-1629: corrected nav-bar for workplace
and added tests
This commit is contained in:
parent
38edeb208e
commit
fd6a57dad3
|
|
@ -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 { Component, DebugElement } from '@angular/core';
|
||||||
import { NavBarComponent } from './nav-bar.component';
|
import { NavBarComponent } from './nav-bar.component';
|
||||||
import { SelectedRouteService } from '../../services/selected-route/selected-route';
|
import { SelectedRouteService } from '../../services/selected-route/selected-route';
|
||||||
|
|
@ -28,7 +28,8 @@ describe('NavBarComponent', () => {
|
||||||
let debugElement: DebugElement;
|
let debugElement: DebugElement;
|
||||||
let route = '';
|
let route = '';
|
||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(
|
||||||
|
waitForAsync(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [NavBarComponent, SvgIconStub],
|
declarations: [NavBarComponent, SvgIconStub],
|
||||||
imports: [MatIconModule, HttpClientTestingModule, MatToolbarModule],
|
imports: [MatIconModule, HttpClientTestingModule, MatToolbarModule],
|
||||||
|
|
@ -37,7 +38,8 @@ describe('NavBarComponent', () => {
|
||||||
{ provide: SelectedRouteService, useValue: SelectedRouteServiceSpy }
|
{ provide: SelectedRouteService, useValue: SelectedRouteServiceSpy }
|
||||||
]
|
]
|
||||||
}).compileComponents();
|
}).compileComponents();
|
||||||
}));
|
})
|
||||||
|
);
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(NavBarComponent);
|
fixture = TestBed.createComponent(NavBarComponent);
|
||||||
|
|
@ -57,6 +59,48 @@ describe('NavBarComponent', () => {
|
||||||
expect(component.title).toBe('Workbaskets');
|
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', () => {
|
it('should toggle sidenav when button clicked', () => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component.toggle).toBe(false);
|
expect(component.toggle).toBe(false);
|
||||||
|
|
|
||||||
|
|
@ -40,19 +40,19 @@ export class NavBarComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(value: string = '') {
|
setTitle(value: string = '') {
|
||||||
if (value.indexOf('workbaskets') === 0) {
|
if (value.includes('workbaskets')) {
|
||||||
this.title = this.titleWorkbaskets;
|
this.title = this.titleWorkbaskets;
|
||||||
} else if (value.indexOf('classifications') === 0) {
|
} else if (value.includes('classifications')) {
|
||||||
this.title = this.titleClassifications;
|
this.title = this.titleClassifications;
|
||||||
} else if (value.indexOf('monitor') === 0) {
|
} else if (value.includes('monitor')) {
|
||||||
this.title = this.titleMonitor;
|
this.title = this.titleMonitor;
|
||||||
} else if (value.indexOf('workplace') === 0) {
|
} else if (value.includes('workplace')) {
|
||||||
this.title = this.titleWorkplace;
|
this.title = this.titleWorkplace;
|
||||||
} else if (value.indexOf('access-items') === 0) {
|
} else if (value.includes('access-items')) {
|
||||||
this.title = this.titleAccessItems;
|
this.title = this.titleAccessItems;
|
||||||
} else if (value.indexOf('history') === 0) {
|
} else if (value.includes('history')) {
|
||||||
this.title = this.titleHistory;
|
this.title = this.titleHistory;
|
||||||
} else if (value.indexOf('settings') === 0) {
|
} else if (value.includes('settings')) {
|
||||||
this.title = this.titleSettings;
|
this.title = this.titleSettings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 { HttpClientModule } from '@angular/common/http';
|
||||||
import { AccessIdsService } from './access-ids.service';
|
import { AccessIdsService } from './access-ids.service';
|
||||||
import { SelectedRouteService } from '../selected-route/selected-route';
|
|
||||||
import { StartupService } from '../startup/startup.service';
|
import { StartupService } from '../startup/startup.service';
|
||||||
import { TaskanaEngineService } from '../taskana-engine/taskana-engine.service';
|
import { TaskanaEngineService } from '../taskana-engine/taskana-engine.service';
|
||||||
import { WindowRefService } from '../window/window.service';
|
import { WindowRefService } from '../window/window.service';
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
import { Injectable, OnInit } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Subject, Observable } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
import { Router, ActivatedRoute, NavigationStart } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SelectedRouteService {
|
export class SelectedRouteService {
|
||||||
public selectedRouteTriggered = new Subject<string>();
|
public selectedRouteTriggered = new Subject<string>();
|
||||||
|
|
||||||
private detailRoutes: Array<string> = [
|
private detailRoutes: Array<string> = [
|
||||||
'workbaskets',
|
|
||||||
'classifications',
|
|
||||||
'monitor',
|
|
||||||
'workplace',
|
'workplace',
|
||||||
'access-items-management',
|
'administration/workbaskets',
|
||||||
'history'
|
'administration/classifications',
|
||||||
|
'monitor',
|
||||||
|
'administration/access-items-management',
|
||||||
|
'history',
|
||||||
|
'settings'
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(private router: Router) {}
|
constructor(private router: Router) {}
|
||||||
|
|
@ -33,6 +34,6 @@ export class SelectedRouteService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private checkUrl(url: string): string {
|
private checkUrl(url: string): string {
|
||||||
return this.detailRoutes.find((routeDetail) => url.indexOf(routeDetail) !== -1) || '';
|
return this.detailRoutes.find((routeDetail) => url.includes(routeDetail)) || '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue