Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aio): add marketing class to AppComponent <aio-shell> on mkt page #16395

Merged
merged 1 commit into from Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions aio/content/navigation.json
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
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
@@ -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
@@ -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.
});