@@ -274,6 +274,18 @@ describe('MatBottomSheet', () => {
274
274
expect ( overlayContainerElement . childElementCount ) . toBe ( 0 ) ;
275
275
} ) ) ;
276
276
277
+ it ( 'should dismiss the bottom sheet when the service is destroyed' , fakeAsync ( ( ) => {
278
+ bottomSheet . open ( PizzaMsg ) ;
279
+ viewContainerFixture . detectChanges ( ) ;
280
+ expect ( overlayContainerElement . childElementCount ) . toBeGreaterThan ( 0 ) ;
281
+
282
+ bottomSheet . ngOnDestroy ( ) ;
283
+ viewContainerFixture . detectChanges ( ) ;
284
+ flush ( ) ;
285
+
286
+ expect ( overlayContainerElement . childElementCount ) . toBe ( 0 ) ;
287
+ } ) ) ;
288
+
277
289
it ( 'should open a new bottom sheet after dismissing a previous sheet' , fakeAsync ( ( ) => {
278
290
let config : MatBottomSheetConfig = { viewContainerRef : testViewContainerRef } ;
279
291
let bottomSheetRef : MatBottomSheetRef < any > = bottomSheet . open ( PizzaMsg , config ) ;
@@ -614,6 +626,23 @@ describe('MatBottomSheet with parent MatBottomSheet', () => {
614
626
expect ( overlayContainerElement . textContent )
615
627
. toContain ( 'Taco' , 'Expected child bottom sheet to be dismissed by opening from parent' ) ;
616
628
} ) ) ;
629
+
630
+ it ( 'should not close parent bottom sheet when child is destroyed' , fakeAsync ( ( ) => {
631
+ parentBottomSheet . open ( PizzaMsg ) ;
632
+ fixture . detectChanges ( ) ;
633
+ tick ( 1000 ) ;
634
+
635
+ expect ( overlayContainerElement . textContent )
636
+ . toContain ( 'Pizza' , 'Expected a bottom sheet to be opened' ) ;
637
+
638
+ childBottomSheet . ngOnDestroy ( ) ;
639
+ fixture . detectChanges ( ) ;
640
+ tick ( 1000 ) ;
641
+
642
+ expect ( overlayContainerElement . textContent )
643
+ . toContain ( 'Pizza' , 'Expected a bottom sheet to stay open' ) ;
644
+ } ) ) ;
645
+
617
646
} ) ;
618
647
619
648
describe ( 'MatBottomSheet with default options' , ( ) => {
0 commit comments