mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore: random test leaks (#4380)
Fixes some unit tests that were leaking elements into other tests.
This commit is contained in:
committed by
Andrew Seguin
parent
c37a2dee66
commit
7884b09d51
@@ -80,6 +80,10 @@ describe('MdAutocomplete', () => {
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(overlayContainerElement);
|
||||
});
|
||||
|
||||
describe('panel toggling', () => {
|
||||
let fixture: ComponentFixture<SimpleAutocomplete>;
|
||||
let input: HTMLInputElement;
|
||||
|
||||
@@ -393,6 +393,10 @@ describe('OverlayContainer theming', () => {
|
||||
overlayContainerElement = overlayContainer.getContainerElement();
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
overlayContainerElement.parentNode.removeChild(overlayContainerElement);
|
||||
});
|
||||
|
||||
it('should be able to set a theme on the overlay container', () => {
|
||||
overlayContainer.themeClass = 'my-theme';
|
||||
expect(overlayContainerElement.classList).toContain('my-theme');
|
||||
|
||||
@@ -17,6 +17,7 @@ describe('GlobalPositonStrategy', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
element.parentNode.removeChild(element);
|
||||
strategy.dispose();
|
||||
});
|
||||
|
||||
|
||||
@@ -43,6 +43,10 @@ describe('CloseScrollStrategy', () => {
|
||||
componentPortal = new ComponentPortal(MozarellaMsg);
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
overlayRef.dispose();
|
||||
});
|
||||
|
||||
it('should detach the overlay as soon as the user scrolls', () => {
|
||||
overlayRef.attach(componentPortal);
|
||||
spyOn(overlayRef, 'detach');
|
||||
|
||||
@@ -43,6 +43,10 @@ describe('RepositionScrollStrategy', () => {
|
||||
componentPortal = new ComponentPortal(PastaMsg);
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
overlayRef.dispose();
|
||||
});
|
||||
|
||||
it('should update the overlay position when the page is scrolled', () => {
|
||||
overlayRef.attach(componentPortal);
|
||||
spyOn(overlayRef, 'updatePosition');
|
||||
|
||||
@@ -349,6 +349,7 @@ describe('MdSnackBar with parent MdSnackBar', () => {
|
||||
let childSnackBar: MdSnackBar;
|
||||
let overlayContainerElement: HTMLElement;
|
||||
let fixture: ComponentFixture<ComponentThatProvidesMdSnackBar>;
|
||||
let liveAnnouncer: LiveAnnouncer;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
@@ -365,8 +366,9 @@ describe('MdSnackBar with parent MdSnackBar', () => {
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(inject([MdSnackBar], (sb: MdSnackBar) => {
|
||||
beforeEach(inject([MdSnackBar, LiveAnnouncer], (sb: MdSnackBar, la: LiveAnnouncer) => {
|
||||
parentSnackBar = sb;
|
||||
liveAnnouncer = la;
|
||||
|
||||
fixture = TestBed.createComponent(ComponentThatProvidesMdSnackBar);
|
||||
childSnackBar = fixture.componentInstance.snackBar;
|
||||
@@ -375,6 +377,7 @@ describe('MdSnackBar with parent MdSnackBar', () => {
|
||||
|
||||
afterEach(() => {
|
||||
overlayContainerElement.innerHTML = '';
|
||||
liveAnnouncer._removeLiveElement();
|
||||
});
|
||||
|
||||
it('should close snackBars opened by parent when opening from child MdSnackBar', fakeAsync(() => {
|
||||
|
||||
@@ -50,6 +50,10 @@ describe('MdTooltip', () => {
|
||||
TestBed.compileComponents();
|
||||
}));
|
||||
|
||||
afterEach(() => {
|
||||
document.body.removeChild(overlayContainerElement);
|
||||
});
|
||||
|
||||
describe('basic usage', () => {
|
||||
let fixture: ComponentFixture<BasicTooltipDemo>;
|
||||
let buttonDebugElement: DebugElement;
|
||||
|
||||
Reference in New Issue
Block a user