forked from angular/material.angular.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomponent-page-header.spec.ts
41 lines (34 loc) · 1.25 KB
/
component-page-header.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {async, TestBed, ComponentFixture} from '@angular/core/testing';
import {MaterialModule} from '@angular/material';
import {CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
import {ComponentPageTitle} from '../page-title/page-title';
import {ComponentPageHeader} from './component-page-header';
describe('ComponentPageHeader', () => {
let fixture: ComponentFixture<ComponentPageHeader>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MaterialModule],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [ComponentPageHeader],
providers: [ComponentPageTitle],
});
fixture = TestBed.createComponent(ComponentPageHeader);
}));
it('should return the title', () => {
const component = fixture.componentInstance;
const title = 'foobar';
fixture.detectChanges();
component._componentPageTitle.title = title;
expect(component.getTitle()).toEqual(title);
});
it('should emit a toggleSideNav event', () => {
const component = fixture.componentInstance;
fixture.detectChanges();
spyOn(component.toggleSidenav, 'emit');
fixture
.nativeElement
.querySelector('.sidenav-toggle')
.click();
expect(component.toggleSidenav.emit).toHaveBeenCalled();
});
});