@@ -17,7 +17,7 @@ import {
1717 Type ,
1818} from '@angular/core' ;
1919import { Direction , Directionality } from '@angular/cdk/bidi' ;
20- import { MockNgZone , dispatchFakeEvent } from '../testing/private' ;
20+ import { dispatchFakeEvent } from '../testing/private' ;
2121import { ComponentPortal , TemplatePortal , CdkPortal } from '@angular/cdk/portal' ;
2222import { Location } from '@angular/common' ;
2323import { SpyLocation } from '@angular/common/testing' ;
@@ -40,7 +40,6 @@ describe('Overlay', () => {
4040 let overlayContainer : OverlayContainer ;
4141 let viewContainerFixture : ComponentFixture < TestComponentWithTemplatePortals > ;
4242 let dir : Direction ;
43- let zone : MockNgZone ;
4443 let mockLocation : SpyLocation ;
4544
4645 function setup ( imports : Type < unknown > [ ] = [ ] ) {
@@ -56,10 +55,6 @@ describe('Overlay', () => {
5655 return fakeDirectionality ;
5756 } ,
5857 } ,
59- {
60- provide : NgZone ,
61- useFactory : ( ) => ( zone = new MockNgZone ( ) ) ,
62- } ,
6358 {
6459 provide : Location ,
6560 useClass : SpyLocation ,
@@ -404,7 +399,6 @@ describe('Overlay', () => {
404399 . toBeTruthy ( ) ;
405400
406401 viewContainerFixture . detectChanges ( ) ;
407- zone . simulateZoneExit ( ) ;
408402
409403 expect ( overlayRef . hostElement . parentElement )
410404 . withContext ( 'Expected host element to have been removed once the zone stabilizes.' )
@@ -510,7 +504,6 @@ describe('Overlay', () => {
510504
511505 overlay . create ( config ) . attach ( componentPortal ) ;
512506 viewContainerFixture . detectChanges ( ) ;
513- zone . simulateZoneExit ( ) ;
514507 tick ( ) ;
515508
516509 expect ( overlayContainerElement . querySelectorAll ( '.fake-positioned' ) . length ) . toBe ( 1 ) ;
@@ -533,7 +526,6 @@ describe('Overlay', () => {
533526 . toBeTruthy ( ) ;
534527
535528 overlayRef . detach ( ) ;
536- zone . simulateZoneExit ( ) ;
537529 tick ( ) ;
538530
539531 overlayRef . attach ( componentPortal ) ;
@@ -573,7 +565,6 @@ describe('Overlay', () => {
573565 const overlayRef = overlay . create ( config ) ;
574566 overlayRef . attach ( componentPortal ) ;
575567 viewContainerFixture . detectChanges ( ) ;
576- zone . simulateZoneExit ( ) ;
577568 tick ( ) ;
578569
579570 expect ( firstStrategy . attach ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -606,7 +597,6 @@ describe('Overlay', () => {
606597 const overlayRef = overlay . create ( config ) ;
607598 overlayRef . attach ( componentPortal ) ;
608599 viewContainerFixture . detectChanges ( ) ;
609- zone . simulateZoneExit ( ) ;
610600 tick ( ) ;
611601
612602 expect ( strategy . attach ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -889,7 +879,6 @@ describe('Overlay', () => {
889879
890880 overlayRef . detach ( ) ;
891881 dispatchFakeEvent ( backdrop , 'transitionend' ) ;
892- zone . simulateZoneExit ( ) ;
893882 viewContainerFixture . detectChanges ( ) ;
894883
895884 backdrop . click ( ) ;
@@ -947,7 +936,6 @@ describe('Overlay', () => {
947936 . toContain ( 'custom-panel-class' ) ;
948937
949938 overlayRef . detach ( ) ;
950- zone . simulateZoneExit ( ) ;
951939 viewContainerFixture . detectChanges ( ) ;
952940 expect ( pane . classList ) . not . toContain ( 'custom-panel-class' , 'Expected class to be removed' ) ;
953941
@@ -971,13 +959,13 @@ describe('Overlay', () => {
971959 . toContain ( 'custom-panel-class' ) ;
972960
973961 overlayRef . detach ( ) ;
974- viewContainerFixture . detectChanges ( ) ;
975-
976- expect ( pane . classList )
977- . withContext ( 'Expected class not to be removed immediately' )
978- . toContain ( 'custom-panel- class' ) ;
979-
980- zone . simulateZoneExit ( ) ;
962+ // Stable emits after zone.run
963+ TestBed . inject ( NgZone ) . run ( ( ) => {
964+ viewContainerFixture . detectChanges ( ) ;
965+ expect ( pane . classList )
966+ . withContext ( 'Expected class not to be removed immediately' )
967+ . toContain ( 'custom-panel-class' ) ;
968+ } ) ;
981969
982970 expect ( pane . classList )
983971 . not . withContext ( 'Expected class to be removed on stable' )
@@ -1061,7 +1049,6 @@ describe('Overlay', () => {
10611049
10621050 overlayRef . attach ( componentPortal ) ;
10631051 viewContainerFixture . detectChanges ( ) ;
1064- zone . simulateZoneExit ( ) ;
10651052 tick ( ) ;
10661053
10671054 expect ( firstStrategy . attach ) . toHaveBeenCalledTimes ( 1 ) ;
@@ -1095,7 +1082,6 @@ describe('Overlay', () => {
10951082
10961083 overlayRef . attach ( componentPortal ) ;
10971084 viewContainerFixture . detectChanges ( ) ;
1098- zone . simulateZoneExit ( ) ;
10991085 tick ( ) ;
11001086
11011087 expect ( strategy . attach ) . toHaveBeenCalledTimes ( 1 ) ;
0 commit comments