From 762088741ac0ec0d051318f999ad5af13748b619 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Sun, 11 Feb 2018 23:51:28 +0100 Subject: [PATCH] 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. --- src/cdk/overlay/position/global-position-strategy.spec.ts | 8 +++++--- .../bottom-sheet-overview-example.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cdk/overlay/position/global-position-strategy.spec.ts b/src/cdk/overlay/position/global-position-strategy.spec.ts index 47fc908324a..5bcbbeaca79 100644 --- a/src/cdk/overlay/position/global-position-strategy.spec.ts +++ b/src/cdk/overlay/position/global-position-strategy.spec.ts @@ -2,7 +2,7 @@ import {NgModule, NgZone, Component} from '@angular/core'; import {TestBed, inject} from '@angular/core/testing'; import {MockNgZone} from '@angular/cdk/testing'; import {PortalModule, ComponentPortal} from '@angular/cdk/portal'; -import {OverlayModule, Overlay, OverlayConfig, OverlayRef} from '../index'; +import {OverlayModule, Overlay, OverlayConfig, OverlayRef, OverlayContainer} from '../index'; describe('GlobalPositonStrategy', () => { @@ -21,12 +21,14 @@ describe('GlobalPositonStrategy', () => { })(); }); - afterEach(() => { + afterEach(inject([OverlayContainer], (overlayContainer: OverlayContainer) => { if (overlayRef) { overlayRef.dispose(); overlayRef = null!; } - }); + + overlayContainer.ngOnDestroy(); + })); function attachOverlay(config: OverlayConfig): OverlayRef { const portal = new ComponentPortal(BlankPortal); diff --git a/src/material-examples/bottom-sheet-overview/bottom-sheet-overview-example.ts b/src/material-examples/bottom-sheet-overview/bottom-sheet-overview-example.ts index 4336540e8ff..1ca0cd42417 100644 --- a/src/material-examples/bottom-sheet-overview/bottom-sheet-overview-example.ts +++ b/src/material-examples/bottom-sheet-overview/bottom-sheet-overview-example.ts @@ -24,7 +24,7 @@ export class BottomSheetOverviewExample { export class BottomSheetOverviewExampleSheet { constructor(private bottomSheetRef: MatBottomSheetRef) {} - onNoClick(event: MouseEvent): void { + openLink(event: MouseEvent): void { this.bottomSheetRef.dismiss(); event.preventDefault(); }