1
1
import { 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' ;
8
3
import { By } from '@angular/platform-browser' ;
9
4
import { MdToolbarModule } from './toolbar' ;
10
5
6
+
11
7
describe ( 'MdToolbar' , ( ) => {
12
- let builder : TestComponentBuilder ;
13
8
14
9
beforeEach ( async ( ( ) => {
15
10
TestBed . configureTestingModule ( {
@@ -20,45 +15,32 @@ describe('MdToolbar', () => {
20
15
TestBed . compileComponents ( ) ;
21
16
} ) ) ;
22
17
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 ;
34
22
35
- expect ( toolbarDebugElement . nativeElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
23
+ testComponent . toolbarColor = 'primary' ;
24
+ fixture . detectChanges ( ) ;
36
25
37
- testComponent . toolbarColor = 'accent' ;
38
- fixture . detectChanges ( ) ;
26
+ expect ( toolbarElement . classList . contains ( 'md-primary' ) ) . toBe ( true ) ;
39
27
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 ( ) ;
42
30
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 ) ;
45
33
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 ( ) ;
48
36
49
- done ( ) ;
50
- } ) ;
37
+ expect ( toolbarElement . classList . contains ( 'md-accent' ) ) . toBe ( false ) ;
38
+ expect ( toolbarElement . classList . contains ( 'md-warn' ) ) . toBe ( true ) ;
51
39
} ) ;
52
-
53
40
} ) ;
54
41
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>` } )
62
44
class TestApp {
63
45
toolbarColor : string ;
64
46
}
0 commit comments