@@ -23,7 +23,7 @@ import {
23
23
24
24
// TODO(josephperrott): Update tests to mock waiting for time to complete for animations.
25
25
26
- describe ( 'MdSnackBar' , ( ) => {
26
+ fdescribe ( 'MdSnackBar' , ( ) => {
27
27
let snackBar : MdSnackBar ;
28
28
let liveAnnouncer : LiveAnnouncer ;
29
29
let overlayContainerElement : HTMLElement ;
@@ -305,6 +305,29 @@ describe('MdSnackBar', () => {
305
305
tick ( 500 ) ;
306
306
} ) ) ;
307
307
308
+ it ( 'should allow manually closing with an action' , fakeAsync ( ( ) => {
309
+ let dismissObservableCompleted = false ;
310
+ let actionObservableCompleted = false ;
311
+ let snackBarRef = snackBar . open ( 'Some content' ) ;
312
+ viewContainerFixture . detectChanges ( ) ;
313
+
314
+ snackBarRef . afterDismissed ( ) . subscribe ( undefined , undefined , ( ) => {
315
+ dismissObservableCompleted = true ;
316
+ } ) ;
317
+ snackBarRef . onAction ( ) . subscribe ( undefined , undefined , ( ) => {
318
+ actionObservableCompleted = true ;
319
+ } ) ;
320
+
321
+ snackBarRef . closeWithAction ( ) ;
322
+ viewContainerFixture . detectChanges ( ) ;
323
+ flushMicrotasks ( ) ;
324
+
325
+ expect ( dismissObservableCompleted ) . toBeTruthy ( 'Expected the snack bar to be dismissed' ) ;
326
+ expect ( actionObservableCompleted ) . toBeTruthy ( 'Expected the snack bar to notify of action' ) ;
327
+
328
+ tick ( 500 ) ;
329
+ } ) ) ;
330
+
308
331
it ( 'should dismiss automatically after a specified timeout' , fakeAsync ( ( ) => {
309
332
let dismissObservableCompleted = false ;
310
333
let config = new MdSnackBarConfig ( ) ;
@@ -386,6 +409,29 @@ describe('MdSnackBar', () => {
386
409
. toBe ( 'Chimichanga' , 'Expected the injected data object to be the one the user provided.' ) ;
387
410
} ) ;
388
411
412
+ it ( 'should allow manually closing with an action' , fakeAsync ( ( ) => {
413
+ let dismissObservableCompleted = false ;
414
+ let actionObservableCompleted = false ;
415
+ const snackBarRef = snackBar . openFromComponent ( BurritosNotification ) ;
416
+ viewContainerFixture . detectChanges ( ) ;
417
+
418
+ snackBarRef . afterDismissed ( ) . subscribe ( undefined , undefined , ( ) => {
419
+ dismissObservableCompleted = true ;
420
+ } ) ;
421
+ snackBarRef . onAction ( ) . subscribe ( undefined , undefined , ( ) => {
422
+ actionObservableCompleted = true ;
423
+ } ) ;
424
+
425
+ snackBarRef . closeWithAction ( ) ;
426
+ viewContainerFixture . detectChanges ( ) ;
427
+ flushMicrotasks ( ) ;
428
+
429
+ expect ( dismissObservableCompleted ) . toBeTruthy ( 'Expected the snack bar to be dismissed' ) ;
430
+ expect ( actionObservableCompleted ) . toBeTruthy ( 'Expected the snack bar to notify of action' ) ;
431
+
432
+ tick ( 500 ) ;
433
+ } ) ) ;
434
+
389
435
} ) ;
390
436
391
437
} ) ;
0 commit comments