From ae37ca7040e4358d0cd8bb6b8d288d834aaf5280 Mon Sep 17 00:00:00 2001 From: Lee Lazarecky Date: Mon, 1 Apr 2019 23:48:35 -0400 Subject: [PATCH] Changes the window title to include the logged in team name. --- ui/src/app/modules/sub-app/sub-app.component.spec.ts | 11 +++++++++-- ui/src/app/modules/sub-app/sub-app.component.ts | 5 ++++- ui/src/index.html | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ui/src/app/modules/sub-app/sub-app.component.spec.ts b/ui/src/app/modules/sub-app/sub-app.component.spec.ts index 355e4f5cc..f34e5bedd 100644 --- a/ui/src/app/modules/sub-app/sub-app.component.spec.ts +++ b/ui/src/app/modules/sub-app/sub-app.component.spec.ts @@ -20,21 +20,24 @@ import {ActivatedRoute} from '@angular/router'; import {TeamService} from '../teams/services/team.service'; import {DataService} from '../data.service'; import {of} from 'rxjs'; -import {instance, mock, when} from 'ts-mockito'; +import {instance, mock, verify, when} from 'ts-mockito'; import {Themes} from '../domain/Theme'; +import {Title} from '@angular/platform-browser'; describe('SubAppComponent', () => { let component: SubAppComponent; let activatedRoute: ActivatedRoute; let teamService: TeamService; let dataService: DataService; + let titleService: Title; beforeEach(() => { activatedRoute = mock(ActivatedRoute); teamService = mock(TeamService); dataService = new DataService(); + titleService = mock(Title); - component = new SubAppComponent(instance(activatedRoute), instance(teamService), dataService); + component = new SubAppComponent(instance(activatedRoute), instance(teamService), dataService, instance(titleService)); }); it('should create', () => { @@ -61,6 +64,10 @@ describe('SubAppComponent', () => { expect(component.teamName).toEqual(fakeName); expect(dataService.team.name).toEqual(fakeName); }); + + it('should change the window title to include the team name', () => { + verify(titleService.setTitle(`${fakeName} | RetroQuest`)).called(); + }); }); describe('emitThemeChanged', () => { diff --git a/ui/src/app/modules/sub-app/sub-app.component.ts b/ui/src/app/modules/sub-app/sub-app.component.ts index 646b0caa9..f130eb367 100644 --- a/ui/src/app/modules/sub-app/sub-app.component.ts +++ b/ui/src/app/modules/sub-app/sub-app.component.ts @@ -20,6 +20,7 @@ import {ActivatedRoute} from '@angular/router'; import {TeamService} from '../teams/services/team.service'; import {DataService} from '../data.service'; import {parseTheme, Themes} from '../domain/Theme'; +import {Title} from '@angular/platform-browser'; @Component({ selector: 'rq-sub-app', @@ -36,7 +37,8 @@ export class SubAppComponent implements OnInit, AfterViewInit { constructor(private activatedRoute: ActivatedRoute, private teamService: TeamService, - private dataService: DataService) { + private dataService: DataService, + private titleService: Title) { } ngOnInit() { @@ -73,6 +75,7 @@ export class SubAppComponent implements OnInit, AfterViewInit { (teamName) => { this.teamName = teamName; this.dataService.team.name = this.teamName; + this.titleService.setTitle(this.teamName + ' | RetroQuest'); } ); } diff --git a/ui/src/index.html b/ui/src/index.html index 5255c4762..71eb530a4 100644 --- a/ui/src/index.html +++ b/ui/src/index.html @@ -20,7 +20,7 @@ - Retroquest + RetroQuest