1- import {
2- waitForAsync ,
3- fakeAsync ,
4- tick ,
5- ComponentFixture ,
6- TestBed ,
7- flush ,
8- } from '@angular/core/testing' ;
1+ import { Direction , Directionality } from '@angular/cdk/bidi' ;
2+ import { CdkPortal , ComponentPortal , TemplatePortal } from '@angular/cdk/portal' ;
3+ import { Location } from '@angular/common' ;
4+ import { SpyLocation } from '@angular/common/testing' ;
95import {
106 Component ,
11- ViewChild ,
12- ViewContainerRef ,
137 ErrorHandler ,
14- Injectable ,
158 EventEmitter ,
16- NgZone ,
9+ Injectable ,
1710 Type ,
18- provideZoneChangeDetection ,
11+ ViewChild ,
12+ ViewContainerRef ,
1913} from '@angular/core' ;
20- import { Direction , Directionality } from '@angular/cdk/bidi' ;
14+ import {
15+ ComponentFixture ,
16+ TestBed ,
17+ fakeAsync ,
18+ flush ,
19+ tick ,
20+ waitForAsync ,
21+ } from '@angular/core/testing' ;
22+ import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
2123import { dispatchFakeEvent } from '../testing/private' ;
22- import { ComponentPortal , TemplatePortal , CdkPortal } from '@angular/cdk/portal' ;
23- import { Location } from '@angular/common' ;
24- import { SpyLocation } from '@angular/common/testing' ;
2524import {
2625 Overlay ,
26+ OverlayConfig ,
2727 OverlayContainer ,
2828 OverlayModule ,
2929 OverlayRef ,
30- OverlayConfig ,
3130 PositionStrategy ,
3231 ScrollStrategy ,
3332} from './index' ;
34- import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
3533
3634describe ( 'Overlay' , ( ) => {
3735 let overlay : Overlay ;
@@ -48,8 +46,6 @@ describe('Overlay', () => {
4846 TestBed . configureTestingModule ( {
4947 imports : [ OverlayModule , ...imports ] ,
5048 providers : [
51- provideZoneChangeDetection ( ) ,
52- provideZoneChangeDetection ( ) ,
5349 {
5450 provide : Directionality ,
5551 useFactory : ( ) => {
@@ -949,26 +945,23 @@ describe('Overlay', () => {
949945 . toContain ( 'custom-panel-class' ) ;
950946 } ) ;
951947
952- it ( 'should wait for the overlay to be detached before removing the panelClass' , ( ) => {
948+ it ( 'should wait for the overlay to be detached before removing the panelClass' , async ( ) => {
953949 const config = new OverlayConfig ( { panelClass : 'custom-panel-class' } ) ;
954950 const overlayRef = overlay . create ( config ) ;
955951
956952 overlayRef . attach ( componentPortal ) ;
957- viewContainerFixture . detectChanges ( ) ;
953+ await viewContainerFixture . whenStable ( ) ;
958954
959955 const pane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
960956 expect ( pane . classList )
961957 . withContext ( 'Expected class to be added' )
962958 . toContain ( 'custom-panel-class' ) ;
963959
964960 overlayRef . detach ( ) ;
965- // Stable emits after zone.run
966- TestBed . inject ( NgZone ) . run ( ( ) => {
967- viewContainerFixture . detectChanges ( ) ;
968- expect ( pane . classList )
969- . withContext ( 'Expected class not to be removed immediately' )
970- . toContain ( 'custom-panel-class' ) ;
971- } ) ;
961+ expect ( pane . classList )
962+ . withContext ( 'Expected class not to be removed immediately' )
963+ . toContain ( 'custom-panel-class' ) ;
964+ await viewContainerFixture . whenStable ( ) ;
972965
973966 expect ( pane . classList )
974967 . not . withContext ( 'Expected class to be removed on stable' )
0 commit comments