chore: random test leaks (#4380)

Fixes some unit tests that were leaking elements into other tests.
This commit is contained in:
Kristiyan Kostadinov
2017-05-04 23:47:25 +02:00
committed by Andrew Seguin
parent c37a2dee66
commit 7884b09d51
7 changed files with 25 additions and 1 deletions
@@ -80,6 +80,10 @@ describe('MdAutocomplete', () => {
TestBed.compileComponents();
}));
afterEach(() => {
document.body.removeChild(overlayContainerElement);
});
describe('panel toggling', () => {
let fixture: ComponentFixture<SimpleAutocomplete>;
let input: HTMLInputElement;
+4
View File
@@ -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');
+4 -1
View File
@@ -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(() => {
+4
View File
@@ -50,6 +50,10 @@ describe('MdTooltip', () => {
TestBed.compileComponents();
}));
afterEach(() => {
document.body.removeChild(overlayContainerElement);
});
describe('basic usage', () => {
let fixture: ComponentFixture<BasicTooltipDemo>;
let buttonDebugElement: DebugElement;