mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore: fix tests leaking overlay containers (#9076)
This commit is contained in:
committed by
Joey Perrott
parent
a779017d7c
commit
bf03d14c98
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user