Skip to content

Commit

Permalink
feat(aio): add marketing class to AppComponent <aio-shell> on mkt page (
Browse files Browse the repository at this point in the history
angular#16395)

Also navigation.json Doc page should be hidden in sidebar, shown in top
  • Loading branch information
wardbell authored and juleskremer committed Aug 24, 2017
1 parent 782683d commit 4dcbfcc
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
3 changes: 1 addition & 2 deletions aio/content/navigation.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
},
{
"url": "docs",
"title": "Docs",
"hidden": true
"title": "Docs"
},
{
"url": "resources",
Expand Down
16 changes: 16 additions & 0 deletions aio/src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,22 @@ describe('AppComponent', () => {
expect(docViewer.innerText).toMatch(/Features/i);
});

const marketingClassName = 'marketing';

it('should not have marketing CSS class on host element for a guide page (guide/pipes)', () => {
locationService.go('guide/pipes');
fixture.detectChanges();
const classes: string[] = fixture.nativeElement.className;
expect(classes).not.toContain(marketingClassName);
});

it('should have marketing CSS class on host element for a marketing page', () => {
locationService.go('features');
fixture.detectChanges();
const classes: string[] = fixture.nativeElement.className;
expect(classes).toContain(marketingClassName);
});

it('should update the document title', () => {
const titleService = TestBed.get(Title);
spyOn(titleService, 'setTitle');
Expand Down
7 changes: 6 additions & 1 deletion aio/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ElementRef, HostListener, OnInit,
import { Component, ElementRef, HostBinding, HostListener, OnInit,
QueryList, ViewChild, ViewChildren } from '@angular/core';
import { MdSidenav } from '@angular/material';

Expand All @@ -25,6 +25,10 @@ export class AppComponent implements OnInit {
pageId: string;
currentDocument: DocumentContents;
footerNodes: NavigationNode[];

@HostBinding('class.marketing')
isMarketing = false;

isStarting = true;
isSideBySide = false;
private isSideNavDoc = false;
Expand Down Expand Up @@ -94,6 +98,7 @@ export class AppComponent implements OnInit {
if (this.previousNavView === currentNode.view) { return; }
this.previousNavView = currentNode.view;
this.isSideNavDoc = currentNode.view === sideNavView;
this.isMarketing = !this.isSideNavDoc;
this.sideNavToggle(this.isSideNavDoc && this.isSideBySide);
});

Expand Down
33 changes: 10 additions & 23 deletions aio/src/app/layout/nav-menu/nav-menu.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

import { NavMenuComponent } from './nav-menu.component';
import { NavigationNode } from 'app/navigation/navigation.service';

// Testing the component class behaviors, independent of its template
// No dependencies, no life-cycle hooks. Just new it and test :)
// Let e2e tests verify how it displays.
describe('NavMenuComponent', () => {
let component: NavMenuComponent;
let fixture: ComponentFixture<NavMenuComponent>;

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ NavMenuComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
});
});

beforeEach(() => {
fixture = TestBed.createComponent(NavMenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
it('should filter out hidden nodes', () => {
const component = new NavMenuComponent();
const nodes: NavigationNode[] =
[ { title: 'a' }, { title: 'b', hidden: 'true'}, { title: 'c'} ];
component.nodes = nodes;
expect(component.filteredNodes).toEqual([ nodes[0], nodes[2] ]);
});

it('should create', () => {
expect(component).toBeTruthy();
});

// TODO: Add TestHostComponent and tests.
});

0 comments on commit 4dcbfcc

Please sign in to comment.