chore: fix tests leaking overlay containers (#9076)

This commit is contained in:
Kristiyan Kostadinov
2017-12-20 22:43:15 +01:00
committed by Joey Perrott
parent a779017d7c
commit bf03d14c98
4 changed files with 18 additions and 10 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ describe('OverlayContainer', () => {
overlayRef.attach(fixture.componentInstance.templatePortal);
fixture.detectChanges();
expect(document.querySelectorAll('.cdk-overlay-container'))
expect(document.querySelector('.cdk-overlay-container'))
.not.toBeNull('Expected the overlay container to be in the DOM after opening an overlay');
// Manually call `ngOnDestroy` because there is no way to force Angular to destroy an
+7 -5
View File
@@ -89,11 +89,12 @@ describe('MatAutocomplete', () => {
return TestBed.createComponent(component);
}
afterEach(() => {
if (overlayContainer) {
overlayContainer.ngOnDestroy();
}
});
afterEach(inject([OverlayContainer], (currentOverlayContainer: OverlayContainer) => {
// Since we're resetting the testing module in some of the tests,
// we can potentially have multiple overlay containers.
currentOverlayContainer.ngOnDestroy();
overlayContainer.ngOnDestroy();
}));
describe('panel toggling', () => {
let fixture: ComponentFixture<SimpleAutocomplete>;
@@ -598,6 +599,7 @@ describe('MatAutocomplete', () => {
});
it('should disable the input when used with a value accessor and without `matInput`', () => {
overlayContainer.ngOnDestroy();
fixture.destroy();
TestBed.resetTestingModule();
+5 -2
View File
@@ -72,9 +72,12 @@ describe('MatMenu', () => {
})();
}));
afterEach(() => {
afterEach(inject([OverlayContainer], (currentOverlayContainer: OverlayContainer) => {
// Since we're resetting the testing module in some of the tests,
// we can potentially have multiple overlay containers.
currentOverlayContainer.ngOnDestroy();
overlayContainer.ngOnDestroy();
});
}));
it('should open the menu as an idempotent operation', () => {
const fixture = TestBed.createComponent(SimpleMenu);
+5 -2
View File
@@ -70,9 +70,12 @@ describe('MatTooltip', () => {
})();
}));
afterEach(() => {
afterEach(inject([OverlayContainer], (currentOverlayContainer: OverlayContainer) => {
// Since we're resetting the testing module in some of the tests,
// we can potentially have multiple overlay containers.
currentOverlayContainer.ngOnDestroy();
overlayContainer.ngOnDestroy();
});
}));
describe('basic usage', () => {
let fixture: ComponentFixture<BasicTooltipDemo>;