1
1
import { Component } from '@angular/core' ;
2
- import { TestBed , async } from '@angular/core/testing' ;
2
+ import { TestBed , async , ComponentFixture } from '@angular/core/testing' ;
3
3
import { By } from '@angular/platform-browser' ;
4
4
import { MdToolbarModule } from './toolbar' ;
5
5
6
6
7
7
describe ( 'MdToolbar' , ( ) => {
8
8
9
+ let fixture : ComponentFixture < TestApp > ;
10
+ let testComponent : TestApp ;
11
+ let toolbarElement : HTMLElement ;
12
+
9
13
beforeEach ( async ( ( ) => {
10
14
TestBed . configureTestingModule ( {
11
15
imports : [ MdToolbarModule . forRoot ( ) ] ,
@@ -15,11 +19,13 @@ describe('MdToolbar', () => {
15
19
TestBed . compileComponents ( ) ;
16
20
} ) ) ;
17
21
18
- it ( 'should apply class based on color attribute' , ( ) => {
19
- let fixture = TestBed . createComponent ( TestApp ) ;
20
- let testComponent = fixture . debugElement . componentInstance ;
21
- let toolbarElement = fixture . debugElement . query ( By . css ( 'md-toolbar' ) ) . nativeElement ;
22
+ beforeEach ( ( ) => {
23
+ fixture = TestBed . createComponent ( TestApp ) ;
24
+ testComponent = fixture . debugElement . componentInstance ;
25
+ toolbarElement = fixture . debugElement . query ( By . css ( 'md-toolbar' ) ) . nativeElement ;
26
+ } ) ;
22
27
28
+ it ( 'should apply class based on color attribute' , ( ) => {
23
29
testComponent . toolbarColor = 'primary' ;
24
30
fixture . detectChanges ( ) ;
25
31
@@ -37,6 +43,11 @@ describe('MdToolbar', () => {
37
43
expect ( toolbarElement . classList . contains ( 'md-accent' ) ) . toBe ( false ) ;
38
44
expect ( toolbarElement . classList . contains ( 'md-warn' ) ) . toBe ( true ) ;
39
45
} ) ;
46
+
47
+ it ( 'should set the toolbar role on the host' , ( ) => {
48
+ expect ( toolbarElement . getAttribute ( 'role' ) ) . toBe ( 'toolbar' ) ;
49
+ } ) ;
50
+
40
51
} ) ;
41
52
42
53
0 commit comments