Skip to content

Commit 71f7d42

Browse files
committed
remove whenStable from fakeAsync test
1 parent 87e0e4d commit 71f7d42

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/lib/tooltip/tooltip.spec.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import {async, ComponentFixture, TestBed, tick, fakeAsync} from '@angular/core/testing';
1+
import {
2+
async, ComponentFixture, TestBed, tick, fakeAsync,
3+
flushMicrotasks
4+
} from '@angular/core/testing';
25
import {Component, DebugElement} from '@angular/core';
36
import {By} from '@angular/platform-browser';
47
import {TooltipPosition, MdTooltip, TOOLTIP_HIDE_DELAY, MdTooltipModule} from './tooltip';
58
import {OverlayContainer} from '../core';
69

710
const initialTooltipMessage = 'initial tooltip message';
811

9-
describe('MdTooltip', () => {
12+
fdescribe('MdTooltip', () => {
1013
let overlayContainerElement: HTMLElement;
1114

1215

@@ -58,9 +61,8 @@ describe('MdTooltip', () => {
5861
expect(tooltipDirective._isTooltipVisible()).toBe(false);
5962

6063
// On animation complete, should expect that the tooltip has been detached.
61-
fixture.whenStable().then(() => {
62-
expect(tooltipDirective._tooltipInstance).toBeNull();
63-
});
64+
flushMicrotasks();
65+
expect(tooltipDirective._tooltipInstance).toBeNull();
6466
}));
6567

6668
it('should not follow through with hide if show is called after', fakeAsync(() => {
@@ -114,8 +116,9 @@ describe('MdTooltip', () => {
114116
});
115117

116118
it('should be removed after parent destroyed', () => {
117-
tooltipDirective._handleMouseEnter(null);
118-
expect(tooltipDirective.visible).toBeTruthy();
119+
tooltipDirective.show();
120+
expect(tooltipDirective._isTooltipVisible()).toBe(true);
121+
119122
fixture.destroy();
120123
expect(overlayContainerElement.childNodes.length).toBe(0);
121124
expect(overlayContainerElement.textContent).toBe('');

src/lib/tooltip/tooltip.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ export class MdTooltip {
8585

8686
/** Dispose the tooltip when destroyed */
8787
ngOnDestroy() {
88-
this._disposeTooltip();
88+
if (this._tooltipInstance) {
89+
this._disposeTooltip();
90+
}
8991
}
9092

9193
/** Shows the tooltip */

0 commit comments

Comments
 (0)