Skip to content

Commit

Permalink
remove whenStable from fakeAsync test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Nov 1, 2016
1 parent 87e0e4d commit 71f7d42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/lib/tooltip/tooltip.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {async, ComponentFixture, TestBed, tick, fakeAsync} from '@angular/core/testing';
import {
async, ComponentFixture, TestBed, tick, fakeAsync,
flushMicrotasks
} from '@angular/core/testing';
import {Component, DebugElement} from '@angular/core';
import {By} from '@angular/platform-browser';
import {TooltipPosition, MdTooltip, TOOLTIP_HIDE_DELAY, MdTooltipModule} from './tooltip';
import {OverlayContainer} from '../core';

const initialTooltipMessage = 'initial tooltip message';

describe('MdTooltip', () => {
fdescribe('MdTooltip', () => {
let overlayContainerElement: HTMLElement;


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

// On animation complete, should expect that the tooltip has been detached.
fixture.whenStable().then(() => {
expect(tooltipDirective._tooltipInstance).toBeNull();
});
flushMicrotasks();
expect(tooltipDirective._tooltipInstance).toBeNull();
}));

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

it('should be removed after parent destroyed', () => {
tooltipDirective._handleMouseEnter(null);
expect(tooltipDirective.visible).toBeTruthy();
tooltipDirective.show();
expect(tooltipDirective._isTooltipVisible()).toBe(true);

fixture.destroy();
expect(overlayContainerElement.childNodes.length).toBe(0);
expect(overlayContainerElement.textContent).toBe('');
Expand Down
4 changes: 3 additions & 1 deletion src/lib/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ export class MdTooltip {

/** Dispose the tooltip when destroyed */
ngOnDestroy() {
this._disposeTooltip();
if (this._tooltipInstance) {
this._disposeTooltip();
}
}

/** Shows the tooltip */
Expand Down

0 comments on commit 71f7d42

Please sign in to comment.