File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -141,15 +141,20 @@ describe('MdDialog', () => {
141
141
} ) ) ;
142
142
143
143
it ( 'should close a dialog and get back a result before it is closed' , async ( ( ) => {
144
- let dialogRef = dialog . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
145
- let beforeCloseCallback = jasmine . createSpy ( 'beforeClose callback' ) ;
144
+ const dialogRef = dialog . open ( PizzaMsg , { viewContainerRef : testViewContainerRef } ) ;
145
+
146
+ // beforeClose should emit before dialog container is destroyed
147
+ const beforeCloseHandler = jasmine . createSpy ( 'beforeClose callback' ) . and . callFake ( ( ) => {
148
+ expect ( overlayContainerElement . querySelector ( 'md-dialog-container' ) )
149
+ . not . toBeNull ( 'dialog container exists when beforeClose is called' ) ;
150
+ } ) ;
146
151
147
- dialogRef . beforeClose ( ) . subscribe ( beforeCloseCallback ) ;
152
+ dialogRef . beforeClose ( ) . subscribe ( beforeCloseHandler ) ;
148
153
dialogRef . close ( 'Bulbasaurus' ) ;
149
154
viewContainerFixture . detectChanges ( ) ;
150
155
151
156
viewContainerFixture . whenStable ( ) . then ( ( ) => {
152
- expect ( beforeCloseCallback ) . toHaveBeenCalledWith ( 'Bulbasaurus' ) ;
157
+ expect ( beforeCloseHandler ) . toHaveBeenCalledWith ( 'Bulbasaurus' ) ;
153
158
expect ( overlayContainerElement . querySelector ( 'md-dialog-container' ) ) . toBeNull ( ) ;
154
159
} ) ;
155
160
} ) ) ;
You can’t perform that action at this time.
0 commit comments