11import { Component } from '@angular/core' ;
2- import {
3- inject ,
4- TestComponentBuilder ,
5- TestBed ,
6- async ,
7- } from '@angular/core/testing' ;
2+ import { TestBed , async } from '@angular/core/testing' ;
83import { By } from '@angular/platform-browser' ;
94import { MdToolbarModule } from './toolbar' ;
105
6+
117describe ( 'MdToolbar' , ( ) => {
12- let builder : TestComponentBuilder ;
138
149 beforeEach ( async ( ( ) => {
1510 TestBed . configureTestingModule ( {
@@ -20,45 +15,32 @@ describe('MdToolbar', () => {
2015 TestBed . compileComponents ( ) ;
2116 } ) ) ;
2217
23- beforeEach ( inject ( [ TestComponentBuilder ] , ( tcb : TestComponentBuilder ) => {
24- builder = tcb ;
25- } ) ) ;
26-
27- it ( 'should apply class based on color attribute' , ( done : ( ) => void ) => {
28- return builder . createAsync ( TestApp ) . then ( ( fixture ) => {
29- let testComponent = fixture . debugElement . componentInstance ;
30- let toolbarDebugElement = fixture . debugElement . query ( By . css ( 'md-toolbar' ) ) ;
31-
32- testComponent . toolbarColor = 'primary' ;
33- fixture . detectChanges ( ) ;
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 ;
3422
35- expect ( toolbarDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
23+ testComponent . toolbarColor = 'primary' ;
24+ fixture . detectChanges ( ) ;
3625
37- testComponent . toolbarColor = 'accent' ;
38- fixture . detectChanges ( ) ;
26+ expect ( toolbarElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
3927
40- expect ( toolbarDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( false ) ;
41- expect ( toolbarDebugElement . nativeElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
28+ testComponent . toolbarColor = 'accent' ;
29+ fixture . detectChanges ( ) ;
4230
43- testComponent . toolbarColor = 'warn' ;
44- fixture . detectChanges ( ) ;
31+ expect ( toolbarElement . classList . contains ( 'md-primary' ) ) . toBe ( false ) ;
32+ expect ( toolbarElement . classList . contains ( 'md-accent' ) ) . toBe ( true ) ;
4533
46- expect ( toolbarDebugElement . nativeElement . classList . contains ( 'md-accent' ) ) . toBe ( false ) ;
47- expect ( toolbarDebugElement . nativeElement . classList . contains ( 'md-warn' ) ) . toBe ( true ) ;
34+ testComponent . toolbarColor = 'warn' ;
35+ fixture . detectChanges ( ) ;
4836
49- done ( ) ;
50- } ) ;
37+ expect ( toolbarElement . classList . contains ( 'md-accent' ) ) . toBe ( false ) ;
38+ expect ( toolbarElement . classList . contains ( 'md-warn' ) ) . toBe ( true ) ;
5139 } ) ;
52-
5340} ) ;
5441
55- @Component ( {
56- selector : 'test-app' ,
57- template : `
58- <md-toolbar [color]="toolbarColor">
59- <span>Test Toolbar</span>
60- </md-toolbar>`
61- } )
42+
43+ @Component ( { template : `<md-toolbar [color]="toolbarColor">Test Toolbar</md-toolbar>` } )
6244class TestApp {
6345 toolbarColor : string ;
6446}
0 commit comments