@@ -4,9 +4,10 @@ import {CdkTableModule} from '@angular/cdk/table';
4
4
import { dispatchKeyboardEvent } from '@angular/cdk/testing' ;
5
5
import { CommonModule } from '@angular/common' ;
6
6
import { Component , ElementRef , Type , ViewChild } from '@angular/core' ;
7
- import { ComponentFixture , fakeAsync , flush , TestBed , tick } from '@angular/core/testing' ;
7
+ import { ComponentFixture , fakeAsync , flush , TestBed , tick , inject } from '@angular/core/testing' ;
8
8
import { FormsModule , NgForm } from '@angular/forms' ;
9
9
import { BidiModule , Direction } from '@angular/cdk/bidi' ;
10
+ import { OverlayContainer } from '@angular/cdk/overlay' ;
10
11
import { BehaviorSubject } from 'rxjs' ;
11
12
12
13
import { CdkPopoverEditColspan , CdkPopoverEditModule , PopoverEditClickOutBehavior } from './index' ;
@@ -322,17 +323,28 @@ describe('CDK Popover Edit', () => {
322
323
describe ( label , ( ) => {
323
324
let component : BaseTestComponent ;
324
325
let fixture : ComponentFixture < BaseTestComponent > ;
326
+ let overlayContainer : OverlayContainer ;
325
327
326
328
beforeEach ( ( ) => {
327
329
TestBed . configureTestingModule ( {
328
330
imports : [ CdkTableModule , CdkPopoverEditModule , CommonModule , FormsModule , BidiModule ] ,
329
331
declarations : [ componentClass ] ,
330
332
} ) . compileComponents ( ) ;
333
+ inject ( [ OverlayContainer ] , ( oc : OverlayContainer ) => {
334
+ overlayContainer = oc ;
335
+ } ) ( ) ;
331
336
fixture = TestBed . createComponent ( componentClass ) ;
332
337
component = fixture . componentInstance ;
333
338
fixture . detectChanges ( ) ;
334
339
} ) ;
335
340
341
+ afterEach ( ( ) => {
342
+ // The overlay container's `ngOnDestroy` won't be called between test runs so we need
343
+ // to call it ourselves, in order to avoid leaking containers between tests and potentially
344
+ // throwing `querySelector` calls.
345
+ overlayContainer . ngOnDestroy ( ) ;
346
+ } ) ;
347
+
336
348
describe ( 'triggering edit' , ( ) => {
337
349
it ( 'shows and hides on-hover content only after a delay' , fakeAsync ( ( ) => {
338
350
const [ row0 , row1 ] = component . getRows ( ) ;
0 commit comments