@@ -618,6 +618,20 @@ describe('Dialog', () => {
618
618
expect ( spy ) . toHaveBeenCalled ( ) ;
619
619
} ) ) ;
620
620
621
+ it ( 'should close all open dialogs on destroy' , fakeAsync ( ( ) => {
622
+ dialog . openFromComponent ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
623
+ dialog . openFromComponent ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
624
+
625
+ viewContainerFixture . detectChanges ( ) ;
626
+ expect ( overlayContainerElement . querySelectorAll ( 'cdk-dialog-container' ) . length ) . toBe ( 2 ) ;
627
+
628
+ dialog . ngOnDestroy ( ) ;
629
+ viewContainerFixture . detectChanges ( ) ;
630
+ flush ( ) ;
631
+
632
+ expect ( overlayContainerElement . querySelectorAll ( 'cdk-dialog-container' ) . length ) . toBe ( 0 ) ;
633
+ } ) ) ;
634
+
621
635
describe ( 'passing in data' , ( ) => {
622
636
it ( 'should be able to pass in data' , ( ) => {
623
637
let config = {
@@ -991,6 +1005,22 @@ describe('Dialog with a parent Dialog', () => {
991
1005
. toBe ( '' , 'Expected closeAll on parent Dialog to close dialog opened by child' ) ;
992
1006
} ) ) ;
993
1007
1008
+ it ( 'should not close the parent dialogs, when a child is destroyed' , fakeAsync ( ( ) => {
1009
+ parentDialog . openFromComponent ( PizzaMsg ) ;
1010
+ fixture . detectChanges ( ) ;
1011
+ flush ( ) ;
1012
+
1013
+ expect ( overlayContainerElement . textContent )
1014
+ . toContain ( 'Pizza' , 'Expected a dialog to be opened' ) ;
1015
+
1016
+ childDialog . ngOnDestroy ( ) ;
1017
+ fixture . detectChanges ( ) ;
1018
+ flush ( ) ;
1019
+
1020
+ expect ( overlayContainerElement . textContent )
1021
+ . toContain ( 'Pizza' , 'Expected a dialog to remain opened' ) ;
1022
+ } ) ) ;
1023
+
994
1024
it ( 'should close the top dialog via the escape key' , fakeAsync ( ( ) => {
995
1025
childDialog . openFromComponent ( PizzaMsg ) ;
996
1026
fixture . detectChanges ( ) ;
0 commit comments