Skip to content

Commit 7620887

Browse files
crisbetommalerba
authored andcommitted
build: overlay container not being cleaned up in global overlay tests (#9878)
* Fixes the `GlobalPositionStrategy` tests leaking `.cdk-overlay-container` instances which can cause flakes in other tests. * Fixes a wrong method name in the bottom sheet overview.
1 parent 008ee07 commit 7620887

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/cdk/overlay/position/global-position-strategy.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {NgModule, NgZone, Component} from '@angular/core';
22
import {TestBed, inject} from '@angular/core/testing';
33
import {MockNgZone} from '@angular/cdk/testing';
44
import {PortalModule, ComponentPortal} from '@angular/cdk/portal';
5-
import {OverlayModule, Overlay, OverlayConfig, OverlayRef} from '../index';
5+
import {OverlayModule, Overlay, OverlayConfig, OverlayRef, OverlayContainer} from '../index';
66

77

88
describe('GlobalPositonStrategy', () => {
@@ -21,12 +21,14 @@ describe('GlobalPositonStrategy', () => {
2121
})();
2222
});
2323

24-
afterEach(() => {
24+
afterEach(inject([OverlayContainer], (overlayContainer: OverlayContainer) => {
2525
if (overlayRef) {
2626
overlayRef.dispose();
2727
overlayRef = null!;
2828
}
29-
});
29+
30+
overlayContainer.ngOnDestroy();
31+
}));
3032

3133
function attachOverlay(config: OverlayConfig): OverlayRef {
3234
const portal = new ComponentPortal(BlankPortal);

src/material-examples/bottom-sheet-overview/bottom-sheet-overview-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class BottomSheetOverviewExample {
2424
export class BottomSheetOverviewExampleSheet {
2525
constructor(private bottomSheetRef: MatBottomSheetRef<BottomSheetOverviewExampleSheet>) {}
2626

27-
onNoClick(event: MouseEvent): void {
27+
openLink(event: MouseEvent): void {
2828
this.bottomSheetRef.dismiss();
2929
event.preventDefault();
3030
}

0 commit comments

Comments
 (0)