@@ -305,6 +305,29 @@ describe('MdSnackBar', () => {
305305 tick ( 500 ) ;
306306 } ) ) ;
307307
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+
308331 it ( 'should dismiss automatically after a specified timeout' , fakeAsync ( ( ) => {
309332 let dismissObservableCompleted = false ;
310333 let config = new MdSnackBarConfig ( ) ;
@@ -386,6 +409,29 @@ describe('MdSnackBar', () => {
386409 . toBe ( 'Chimichanga' , 'Expected the injected data object to be the one the user provided.' ) ;
387410 } ) ;
388411
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+
389435 } ) ;
390436
391437} ) ;
0 commit comments