1
+ import {
2
+ inject ,
3
+ injectAsync ,
4
+ ComponentFixture ,
5
+ TestComponentBuilder ,
6
+ beforeEachProviders ,
7
+ } from 'angular2/testing' ;
1
8
import {
2
9
it ,
3
10
iit ,
4
11
describe ,
5
12
ddescribe ,
6
13
expect ,
7
- inject ,
8
- injectAsync ,
9
- TestComponentBuilder ,
10
- beforeEachProviders ,
11
14
beforeEach ,
12
- } from 'angular2/testing' ;
15
+ } from '../../core/facade/testing' ;
16
+ import {
17
+ getComputedStyle
18
+ } from '../../core/facade/html' ;
13
19
import { provide , Component , DebugElement } from 'angular2/core' ;
14
20
import { By } from 'angular2/platform/browser' ;
15
-
16
- import { MdSidenav , MdSidenavLayout , MD_SIDENAV_DIRECTIVES } from './sidenav' ;
17
- import { AsyncTestFn , FunctionWithParamTokens } from 'angular2/testing' ;
18
- import { ComponentFixture } from 'angular2/testing' ;
19
- import { EventEmitter } from 'angular2/core' ;
20
21
import { Predicate } from 'angular2/src/facade/collection' ;
21
22
import { PromiseWrapper } from 'angular2/src/facade/promise' ;
22
23
import { TimerWrapper } from 'angular2/src/facade/async' ;
24
+ import { MdSidenav , MdSidenavLayout , MD_SIDENAV_DIRECTIVES } from './sidenav' ;
23
25
24
26
25
27
function wait ( msec : number ) {
26
28
let completer = PromiseWrapper . completer ( ) ;
27
- TimerWrapper . setTimeout ( completer . resolve , msec ) ;
29
+ TimerWrapper . setTimeout ( ( ) => {
30
+ completer . resolve ( null ) ;
31
+ } , msec ) ;
28
32
return completer . promise ;
29
33
}
30
34
@@ -38,7 +42,7 @@ function waitOnEvent(fixture: ComponentFixture,
38
42
let completer = PromiseWrapper . completer ( ) ;
39
43
let component : any = fixture . debugElement . query ( by ) . componentInstance ;
40
44
component [ propertyName ] . subscribe ( ( ) => {
41
- completer . resolve ( ) ;
45
+ completer . resolve ( null ) ;
42
46
} ) ;
43
47
return completer . promise ;
44
48
}
@@ -63,7 +67,7 @@ export function main() {
63
67
testComponent = fixture . debugElement . componentInstance ;
64
68
fixture . detectChanges ( ) ;
65
69
return wait ( 1 ) ;
66
- } ) . then ( ( f ) => {
70
+ } ) . then ( ( _ : any ) => {
67
71
let openButtonElement = fixture . debugElement . query ( By . css ( '.open' ) ) ;
68
72
openButtonElement . nativeElement . click ( ) ;
69
73
fixture . detectChanges ( ) ;
@@ -81,8 +85,8 @@ export function main() {
81
85
82
86
let sidenavElement = fixture . debugElement . query ( By . css ( 'md-sidenav' ) ) ;
83
87
let sidenavBackdropElement = fixture . debugElement . query ( By . css ( '.md-sidenav-backdrop' ) ) ;
84
- expect ( window . getComputedStyle ( sidenavElement . nativeElement ) . visibility ) . toEqual ( 'visible' ) ;
85
- expect ( window . getComputedStyle ( sidenavBackdropElement . nativeElement ) . visibility ) . toEqual ( 'visible' ) ;
88
+ expect ( getComputedStyle ( sidenavElement . nativeElement ) . visibility ) . toEqual ( 'visible' ) ;
89
+ expect ( getComputedStyle ( sidenavBackdropElement . nativeElement ) . visibility ) . toEqual ( 'visible' ) ;
86
90
87
91
// Close it.
88
92
let closeButtonElement = fixture . debugElement . query ( By . css ( '.close' ) ) ;
@@ -107,10 +111,10 @@ export function main() {
107
111
108
112
let sidenavElement = fixture . debugElement . query ( By . css ( 'md-sidenav' ) ) ;
109
113
let sidenavBackdropElement = fixture . debugElement . query ( By . css ( '.md-sidenav-backdrop' ) ) ;
110
- expect ( window . getComputedStyle ( sidenavElement . nativeElement ) . visibility ) . toEqual ( 'hidden' ) ;
111
- expect ( window . getComputedStyle ( sidenavBackdropElement . nativeElement ) . visibility ) . toEqual ( 'hidden' ) ;
114
+ expect ( getComputedStyle ( sidenavElement . nativeElement ) . visibility ) . toEqual ( 'hidden' ) ;
115
+ expect ( getComputedStyle ( sidenavBackdropElement . nativeElement ) . visibility ) . toEqual ( 'hidden' ) ;
112
116
} )
113
- . then ( done , done . fail ) ;
117
+ . then ( ( _ : any ) => { done ( ) ; } ) ;
114
118
} , 8000 ) ;
115
119
116
120
it ( 'open() and close() return a promise that resolves after the animation ended' ,
@@ -149,7 +153,7 @@ export function main() {
149
153
} )
150
154
. then ( ( _ : any ) => promise )
151
155
. then ( ( _ : any ) => expect ( called ) . toBe ( true ) )
152
- . then ( done , done . fail ) ;
156
+ . then ( ( _ : any ) => { done ( ) ; } ) ;
153
157
} , 8000 ) ;
154
158
155
159
it ( 'open() twice returns the same promise' , ( done : any ) => {
@@ -175,15 +179,14 @@ export function main() {
175
179
promise = sidenav . close ( ) ;
176
180
expect ( sidenav . close ( ) ) . toBe ( promise ) ;
177
181
} )
178
- . then ( done , done . fail ) ;
182
+ . then ( ( _ : any ) => { done ( ) ; } ) ;
179
183
} ) ;
180
184
181
185
it ( 'open() then close() cancel animations when called too fast' ,
182
186
( done : any ) => {
183
187
let fixture : ComponentFixture ;
184
188
let sidenav : MdSidenav ;
185
189
186
- let openPromise : Promise < void > ;
187
190
let closePromise : Promise < void > ;
188
191
let openCalled : boolean = false ;
189
192
let openCancelled : boolean = false ;
@@ -194,7 +197,7 @@ export function main() {
194
197
fixture = f ;
195
198
sidenav = fixture . debugElement . query ( By . directive ( MdSidenav ) ) . componentInstance ;
196
199
197
- openPromise = sidenav . open ( ) . then ( ( _ : any ) => {
200
+ sidenav . open ( ) . then ( ( _ : any ) => {
198
201
openCalled = true ;
199
202
} ,
200
203
( ) => {
@@ -208,7 +211,7 @@ export function main() {
208
211
. then ( ( _ : any ) => {
209
212
closePromise = sidenav . close ( ) . then ( ( _ : any ) => {
210
213
closeCalled = true ;
211
- } , done . fail ) ;
214
+ } ) ;
212
215
return wait ( 1 ) ;
213
216
} )
214
217
. then ( ( _ : any ) => {
@@ -220,17 +223,15 @@ export function main() {
220
223
expect ( openCancelled ) . toBe ( true ) ;
221
224
expect ( closeCalled ) . toBe ( true ) ;
222
225
} )
223
- . then ( done , done . fail ) ;
226
+ . then ( ( _ : any ) => { done ( ) ; } ) ;
224
227
} , 8000 ) ;
225
228
226
229
it ( 'close() then open() cancel animations when called too fast' ,
227
230
( done : any ) => {
228
- let testComponent : BasicTestApp ;
229
231
let fixture : ComponentFixture ;
230
232
let sidenav : MdSidenav ;
231
233
232
234
let openPromise : Promise < void > ;
233
- let closePromise : Promise < void > ;
234
235
let closeCalled : boolean = false ;
235
236
let closeCancelled : boolean = false ;
236
237
let openCalled : boolean = false ;
@@ -250,10 +251,9 @@ export function main() {
250
251
} )
251
252
. then ( ( _ : any ) => {
252
253
// Then close and check behavior.
253
- closePromise = sidenav . close ( ) . then ( ( _ : any ) => {
254
+ sidenav . close ( ) . then ( ( _ : any ) => {
254
255
closeCalled = true ;
255
- } ,
256
- ( ) => {
256
+ } , ( ) => {
257
257
closeCancelled = true ;
258
258
} ) ;
259
259
} )
@@ -276,7 +276,7 @@ export function main() {
276
276
expect ( closeCancelled ) . toBe ( true ) ;
277
277
expect ( openCalled ) . toBe ( true ) ;
278
278
} )
279
- . then ( done , done . fail ) ;
279
+ . then ( ( _ : any ) => { done ( ) ; } ) ;
280
280
} , 8000 ) ;
281
281
} ) ;
282
282
} ) ;
0 commit comments