diff --git a/aio/src/app/app.component.html b/aio/src/app/app.component.html index e9cc05ae21..3bdf8e25aa 100644 --- a/aio/src/app/app.component.html +++ b/aio/src/app/app.component.html @@ -16,7 +16,7 @@ -
+
diff --git a/aio/src/app/app.component.spec.ts b/aio/src/app/app.component.spec.ts index b21347bf8a..3da89a4604 100644 --- a/aio/src/app/app.component.spec.ts +++ b/aio/src/app/app.component.spec.ts @@ -104,6 +104,33 @@ describe('AppComponent', () => { }); }); + describe('pageId', () => { + let locationService: MockLocationService; + + beforeEach(() => { + locationService = fixture.debugElement.injector.get(LocationService) as any; + }); + + it('should set the id of the doc viewer container based on the current url', () => { + const container = fixture.debugElement.query(By.css('section.sidenav-content')); + + locationService.urlSubject.next('guide/pipes'); + fixture.detectChanges(); + expect(component.pageId).toEqual('guide-pipes'); + expect(container.properties['id']).toEqual('guide-pipes'); + + locationService.urlSubject.next('news'); + fixture.detectChanges(); + expect(component.pageId).toEqual('news'); + expect(container.properties['id']).toEqual('news'); + + locationService.urlSubject.next(''); + fixture.detectChanges(); + expect(component.pageId).toEqual('home'); + expect(container.properties['id']).toEqual('home'); + }); + }); + describe('currentDocument', () => { console.log('PENDING: AppComponent currentDocument'); }); diff --git a/aio/src/app/app.component.ts b/aio/src/app/app.component.ts index 4fcd36630c..5a6f0bd445 100644 --- a/aio/src/app/app.component.ts +++ b/aio/src/app/app.component.ts @@ -21,6 +21,7 @@ const sideNavView = 'SideNav'; export class AppComponent implements OnInit { currentNode: CurrentNode; + pageId: string; currentDocument: DocumentContents; footerNodes: NavigationNode[]; isSideBySide = false; @@ -70,6 +71,7 @@ export class AppComponent implements OnInit { this.navigationService.currentNode.subscribe(currentNode => { this.currentNode = currentNode; + this.pageId = this.currentNode.url.replace('/', '-') || 'home'; // Toggle the sidenav if the kind of view changed if (this.previousNavView === currentNode.view) { return; } @@ -131,4 +133,5 @@ export class AppComponent implements OnInit { sideNavToggle(value?: boolean) { this.sidenav.toggle(value); } + }