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 { 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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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<string>();
|
||||
|
||||
private detailRoutes: Array<string> = [
|
||||
'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)) || '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue