diff --git a/src/lib/tooltip/tooltip.spec.ts b/src/lib/tooltip/tooltip.spec.ts index d4b7984b057f..6a36abb506a7 100644 --- a/src/lib/tooltip/tooltip.spec.ts +++ b/src/lib/tooltip/tooltip.spec.ts @@ -7,7 +7,7 @@ import {MdTooltipModule} from './tooltip'; const initialTooltipMessage = 'initial tooltip message'; -describe('MdTooltip', () => { +fdescribe('MdTooltip', () => { let overlayContainerElement: HTMLElement; @@ -49,14 +49,29 @@ describe('MdTooltip', () => { fixture.detectChanges(); expect(overlayContainerElement.textContent).toContain(initialTooltipMessage); + // After hide called, a timeout delay is created that will to hide the tooltip. tooltipDirective.hide(); expect(tooltipDirective._isTooltipVisible()).toBe(true); - // After hidden, expect that the tooltip is not visible. + // After the tooltip delay elapses, expect that the tooltip is not visible. tick(TOOLTIP_HIDE_DELAY); expect(tooltipDirective._isTooltipVisible()).toBe(false); })); + fit('should not follow through with hide if show is called after', fakeAsync(() => { + tooltipDirective.show(); + expect(tooltipDirective._isTooltipVisible()).toBe(true); + + // After hide called, a timeout delay is created that will to hide the tooltip. + tooltipDirective.hide(); + expect(tooltipDirective._isTooltipVisible()).toBe(true); + + // Before delay time has passed, call show which should cancel intent to hide tooltip. + tooltipDirective.show(); + tick(TOOLTIP_HIDE_DELAY); + expect(tooltipDirective._isTooltipVisible()).toBe(true); + })); + it('should remove the tooltip when changing position', () => { const initialPosition: TooltipPosition = 'below'; const changedPosition: TooltipPosition = 'above'; diff --git a/src/lib/tooltip/tooltip.ts b/src/lib/tooltip/tooltip.ts index 8231145904ff..d9786910aeb8 100644 --- a/src/lib/tooltip/tooltip.ts +++ b/src/lib/tooltip/tooltip.ts @@ -245,6 +245,11 @@ export class TooltipComponent { } } + /** + * Interactions on the HTML body should close the tooltip immediately as defined in the + * material design spec. + * https://material.google.com/components/tooltips.html#tooltips-interaction + */ _handleBodyInteraction(): void { if (this._closeOnInteraction) { this.hide(0);