Skip to content

test(popover-edit): fix tests leaking overlay containers #16103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cdk-experimental/popover-edit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ng_test_library(
"//src/cdk/keycodes",
"//src/cdk/table",
"//src/cdk/testing",
"//src/cdk/overlay",
],
)

Expand Down
14 changes: 13 additions & 1 deletion src/cdk-experimental/popover-edit/popover-edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import {CdkTableModule} from '@angular/cdk/table';
import {dispatchKeyboardEvent} from '@angular/cdk/testing';
import {CommonModule} from '@angular/common';
import {Component, ElementRef, Type, ViewChild} from '@angular/core';
import {ComponentFixture, fakeAsync, flush, TestBed, tick} from '@angular/core/testing';
import {ComponentFixture, fakeAsync, flush, TestBed, tick, inject} from '@angular/core/testing';
import {FormsModule, NgForm} from '@angular/forms';
import {BidiModule, Direction} from '@angular/cdk/bidi';
import {OverlayContainer} from '@angular/cdk/overlay';
import {BehaviorSubject} from 'rxjs';

import {CdkPopoverEditColspan, CdkPopoverEditModule, PopoverEditClickOutBehavior} from './index';
Expand Down Expand Up @@ -322,17 +323,28 @@ describe('CDK Popover Edit', () => {
describe(label, () => {
let component: BaseTestComponent;
let fixture: ComponentFixture<BaseTestComponent>;
let overlayContainer: OverlayContainer;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [CdkTableModule, CdkPopoverEditModule, CommonModule, FormsModule, BidiModule],
declarations: [componentClass],
}).compileComponents();
inject([OverlayContainer], (oc: OverlayContainer) => {
overlayContainer = oc;
})();
fixture = TestBed.createComponent(componentClass);
component = fixture.componentInstance;
fixture.detectChanges();
});

afterEach(() => {
// The overlay container's `ngOnDestroy` won't be called between test runs so we need
// to call it ourselves, in order to avoid leaking containers between tests and potentially
// throwing `querySelector` calls.
overlayContainer.ngOnDestroy();
});

describe('triggering edit', () => {
it('shows and hides on-hover content only after a delay', fakeAsync(() => {
const [row0, row1] = component.getRows();
Expand Down
1 change: 1 addition & 0 deletions src/material-experimental/popover-edit/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ng_test_library(
"//src/cdk/collections",
"//src/cdk/keycodes",
"//src/cdk/testing",
"//src/cdk/overlay",
"//src/cdk-experimental/popover-edit",
"//src/material/table",
],
Expand Down
14 changes: 13 additions & 1 deletion src/material-experimental/popover-edit/popover-edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {MatTableModule} from '@angular/material/table';
import {dispatchKeyboardEvent} from '@angular/cdk/testing';
import {CommonModule} from '@angular/common';
import {Component, ElementRef, Type, ViewChild} from '@angular/core';
import {ComponentFixture, fakeAsync, flush, TestBed, tick} from '@angular/core/testing';
import {ComponentFixture, fakeAsync, flush, TestBed, tick, inject} from '@angular/core/testing';
import {FormsModule, NgForm} from '@angular/forms';
import {OverlayContainer} from '@angular/cdk/overlay';
import {BehaviorSubject} from 'rxjs';

import {
Expand Down Expand Up @@ -263,17 +264,28 @@ describe('Material Popover Edit', () => {
describe(label, () => {
let component: BaseTestComponent;
let fixture: ComponentFixture<BaseTestComponent>;
let overlayContainer: OverlayContainer;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [MatTableModule, MatPopoverEditModule, CommonModule, FormsModule],
declarations: [componentClass],
}).compileComponents();
inject([OverlayContainer], (oc: OverlayContainer) => {
overlayContainer = oc;
})();
fixture = TestBed.createComponent(componentClass);
component = fixture.componentInstance;
fixture.detectChanges();
});

afterEach(() => {
// The overlay container's `ngOnDestroy` won't be called between test runs so we need
// to call it ourselves, in order to avoid leaking containers between tests and potentially
// throwing `querySelector` calls.
overlayContainer.ngOnDestroy();
});

describe('triggering edit', () => {
it('shows and hides on-hover content only after a delay', fakeAsync(() => {
const [row0, row1] = component.getRows();
Expand Down