Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

Commit

Permalink
Changes the window title to include the logged in team name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Druage committed Apr 2, 2019
1 parent ab905a5 commit ae37ca7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 9 additions & 2 deletions ui/src/app/modules/sub-app/sub-app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/modules/sub-app/sub-app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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() {
Expand Down Expand Up @@ -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');
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Retroquest</title>
<title>RetroQuest</title>
<base href="/">

<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
Expand Down

0 comments on commit ae37ca7

Please sign in to comment.