Skip to content

Commit b0cb8ed

Browse files
committed
add test for showing after hiding
1 parent 827b434 commit b0cb8ed

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/lib/tooltip/tooltip.spec.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {MdTooltipModule} from './tooltip';
77

88
const initialTooltipMessage = 'initial tooltip message';
99

10-
describe('MdTooltip', () => {
10+
fdescribe('MdTooltip', () => {
1111
let overlayContainerElement: HTMLElement;
1212

1313

@@ -49,14 +49,29 @@ describe('MdTooltip', () => {
4949
fixture.detectChanges();
5050
expect(overlayContainerElement.textContent).toContain(initialTooltipMessage);
5151

52+
// After hide called, a timeout delay is created that will to hide the tooltip.
5253
tooltipDirective.hide();
5354
expect(tooltipDirective._isTooltipVisible()).toBe(true);
5455

55-
// After hidden, expect that the tooltip is not visible.
56+
// After the tooltip delay elapses, expect that the tooltip is not visible.
5657
tick(TOOLTIP_HIDE_DELAY);
5758
expect(tooltipDirective._isTooltipVisible()).toBe(false);
5859
}));
5960

61+
fit('should not follow through with hide if show is called after', fakeAsync(() => {
62+
tooltipDirective.show();
63+
expect(tooltipDirective._isTooltipVisible()).toBe(true);
64+
65+
// After hide called, a timeout delay is created that will to hide the tooltip.
66+
tooltipDirective.hide();
67+
expect(tooltipDirective._isTooltipVisible()).toBe(true);
68+
69+
// Before delay time has passed, call show which should cancel intent to hide tooltip.
70+
tooltipDirective.show();
71+
tick(TOOLTIP_HIDE_DELAY);
72+
expect(tooltipDirective._isTooltipVisible()).toBe(true);
73+
}));
74+
6075
it('should remove the tooltip when changing position', () => {
6176
const initialPosition: TooltipPosition = 'below';
6277
const changedPosition: TooltipPosition = 'above';

src/lib/tooltip/tooltip.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ export class TooltipComponent {
245245
}
246246
}
247247

248+
/**
249+
* Interactions on the HTML body should close the tooltip immediately as defined in the
250+
* material design spec.
251+
* https://material.google.com/components/tooltips.html#tooltips-interaction
252+
*/
248253
_handleBodyInteraction(): void {
249254
if (this._closeOnInteraction) {
250255
this.hide(0);

0 commit comments

Comments
 (0)