@@ -2239,7 +2239,8 @@ describe('$mdPanel', function() {
2239
2239
spyOn ( obj , 'callback' ) ;
2240
2240
2241
2241
panelRef . registerInterceptor ( interceptorTypes . CLOSE , obj . callback ) ;
2242
- callInteceptors ( 'CLOSE' ) ;
2242
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) ;
2243
+ flushPanel ( ) ;
2243
2244
2244
2245
expect ( obj . callback ) . toHaveBeenCalledWith ( panelRef ) ;
2245
2246
} ) ;
@@ -2254,8 +2255,8 @@ describe('$mdPanel', function() {
2254
2255
panelRef . registerInterceptor ( interceptorTypes . CLOSE , makePromise ( 2 ) ) ;
2255
2256
panelRef . registerInterceptor ( interceptorTypes . CLOSE , makePromise ( 3 ) ) ;
2256
2257
2257
- callInteceptors ( ' CLOSE' ) . then ( obj . callback ) ;
2258
- $rootScope . $apply ( ) ;
2258
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) . then ( obj . callback ) ;
2259
+ flushPanel ( ) ;
2259
2260
2260
2261
expect ( results ) . toEqual ( [ 3 , 2 , 1 ] ) ;
2261
2262
expect ( obj . callback ) . toHaveBeenCalled ( ) ;
@@ -2279,8 +2280,8 @@ describe('$mdPanel', function() {
2279
2280
panelRef . registerInterceptor ( interceptorTypes . CLOSE , makePromise ( 2 ) ) ;
2280
2281
panelRef . registerInterceptor ( interceptorTypes . CLOSE , makePromise ( 3 ) ) ;
2281
2282
2282
- callInteceptors ( ' CLOSE' ) . catch ( obj . callback ) ;
2283
- $rootScope . $apply ( ) ;
2283
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) . catch ( obj . callback ) ;
2284
+ flushPanel ( ) ;
2284
2285
2285
2286
expect ( results ) . toEqual ( [ 3 , 2 ] ) ;
2286
2287
expect ( obj . callback ) . toHaveBeenCalled ( ) ;
@@ -2307,8 +2308,8 @@ describe('$mdPanel', function() {
2307
2308
return $q . resolve ( ) ;
2308
2309
} ) ;
2309
2310
2310
- callInteceptors ( ' CLOSE' ) . catch ( obj . callback ) ;
2311
- $rootScope . $apply ( ) ;
2311
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) . catch ( obj . callback ) ;
2312
+ flushPanel ( ) ;
2312
2313
2313
2314
expect ( obj . callback ) . toHaveBeenCalled ( ) ;
2314
2315
} ) ;
@@ -2318,8 +2319,8 @@ describe('$mdPanel', function() {
2318
2319
2319
2320
spyOn ( obj , 'callback' ) ;
2320
2321
2321
- callInteceptors ( ' CLOSE' ) . then ( obj . callback ) ;
2322
- $rootScope . $apply ( ) ;
2322
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) . then ( obj . callback ) ;
2323
+ flushPanel ( ) ;
2323
2324
2324
2325
expect ( obj . callback ) . toHaveBeenCalled ( ) ;
2325
2326
} ) ;
@@ -2330,12 +2331,14 @@ describe('$mdPanel', function() {
2330
2331
spyOn ( obj , 'callback' ) ;
2331
2332
2332
2333
panelRef . registerInterceptor ( interceptorTypes . CLOSE , obj . callback ) ;
2333
- callInteceptors ( 'CLOSE' ) ;
2334
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) ;
2335
+ flushPanel ( ) ;
2334
2336
2335
2337
expect ( obj . callback ) . toHaveBeenCalledTimes ( 1 ) ;
2336
2338
2337
2339
panelRef . removeInterceptor ( interceptorTypes . CLOSE , obj . callback ) ;
2338
- panelRef . _callInterceptors ( 'CLOSE' ) ;
2340
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) ;
2341
+ flushPanel ( ) ;
2339
2342
2340
2343
expect ( obj . callback ) . toHaveBeenCalledTimes ( 1 ) ;
2341
2344
} ) ;
@@ -2352,15 +2355,17 @@ describe('$mdPanel', function() {
2352
2355
panelRef . registerInterceptor ( interceptorTypes . CLOSE , obj . callback ) ;
2353
2356
panelRef . registerInterceptor ( 'onOpen' , obj . otherCallback ) ;
2354
2357
2355
- callInteceptors ( 'CLOSE' ) ;
2356
- callInteceptors ( 'onOpen' ) ;
2358
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) ;
2359
+ panelRef . _callInterceptors ( 'onOpen' ) ;
2360
+ flushPanel ( ) ;
2357
2361
2358
2362
expect ( obj . callback ) . toHaveBeenCalledTimes ( 1 ) ;
2359
2363
expect ( obj . otherCallback ) . toHaveBeenCalledTimes ( 1 ) ;
2360
2364
2361
2365
panelRef . removeAllInterceptors ( ) ;
2362
- callInteceptors ( 'CLOSE' ) ;
2363
- callInteceptors ( 'onOpen' ) ;
2366
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) ;
2367
+ panelRef . _callInterceptors ( 'onOpen' ) ;
2368
+ flushPanel ( ) ;
2364
2369
2365
2370
expect ( obj . callback ) . toHaveBeenCalledTimes ( 1 ) ;
2366
2371
expect ( obj . otherCallback ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -2378,15 +2383,17 @@ describe('$mdPanel', function() {
2378
2383
panelRef . registerInterceptor ( interceptorTypes . CLOSE , obj . callback ) ;
2379
2384
panelRef . registerInterceptor ( 'onOpen' , obj . otherCallback ) ;
2380
2385
2381
- callInteceptors ( 'CLOSE' ) ;
2382
- callInteceptors ( 'onOpen' ) ;
2386
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) ;
2387
+ panelRef . _callInterceptors ( 'onOpen' ) ;
2388
+ flushPanel ( ) ;
2383
2389
2384
2390
expect ( obj . callback ) . toHaveBeenCalledTimes ( 1 ) ;
2385
2391
expect ( obj . otherCallback ) . toHaveBeenCalledTimes ( 1 ) ;
2386
2392
2387
2393
panelRef . removeAllInterceptors ( interceptorTypes . CLOSE ) ;
2388
- callInteceptors ( 'CLOSE' ) ;
2389
- callInteceptors ( 'onOpen' ) ;
2394
+ panelRef . _callInterceptors ( interceptorTypes . CLOSE ) ;
2395
+ panelRef . _callInterceptors ( 'onOpen' ) ;
2396
+ flushPanel ( ) ;
2390
2397
2391
2398
expect ( obj . callback ) . toHaveBeenCalledTimes ( 1 ) ;
2392
2399
expect ( obj . otherCallback ) . toHaveBeenCalledTimes ( 2 ) ;
@@ -2401,7 +2408,8 @@ describe('$mdPanel', function() {
2401
2408
2402
2409
expect ( panelRef . isAttached ) . toBe ( true ) ;
2403
2410
2404
- closePanel ( ) ;
2411
+ panelRef . close ( ) . catch ( angular . noop ) ;
2412
+ flushPanel ( ) ;
2405
2413
2406
2414
expect ( panelRef . isAttached ) . toBe ( true ) ;
2407
2415
} ) ;
@@ -2512,15 +2520,4 @@ describe('$mdPanel', function() {
2512
2520
$rootScope . $apply ( ) ;
2513
2521
$material . flushOutstandingAnimations ( ) ;
2514
2522
}
2515
-
2516
- function callInteceptors ( type ) {
2517
- if ( panelRef ) {
2518
- var promise = panelRef . _callInterceptors (
2519
- $mdPanel . interceptorTypes [ type ] || type
2520
- ) ;
2521
-
2522
- flushPanel ( ) ;
2523
- return promise ;
2524
- }
2525
- }
2526
2523
} ) ;
0 commit comments