fix(tooltip): don't show tooltip if message is empty or not present (#2081)

Closes #2078
This commit is contained in:
Martin Belev
2016-12-06 08:52:45 +02:00
committed by mmalerba
parent 9d20a347c2
commit 2701aaecfd
2 changed files with 28 additions and 0 deletions
+24
View File
@@ -74,6 +74,30 @@ describe('MdTooltip', () => {
expect(tooltipDirective._tooltipInstance).toBeNull();
}));
it('should not show tooltip if message is not present or empty', fakeAsync(() => {
expect(tooltipDirective._tooltipInstance).toBeUndefined();
tooltipDirective.message = undefined;
fixture.detectChanges();
tooltipDirective.show();
expect(tooltipDirective._tooltipInstance).toBeUndefined();
tooltipDirective.message = null;
fixture.detectChanges();
tooltipDirective.show();
expect(tooltipDirective._tooltipInstance).toBeUndefined();
tooltipDirective.message = '';
fixture.detectChanges();
tooltipDirective.show();
expect(tooltipDirective._tooltipInstance).toBeUndefined();
tooltipDirective.message = ' ';
fixture.detectChanges();
tooltipDirective.show();
expect(tooltipDirective._tooltipInstance).toBeUndefined();
}));
it('should not follow through with hide if show is called after', fakeAsync(() => {
tooltipDirective.show();
expect(tooltipDirective._isTooltipVisible()).toBe(true);
+4
View File
@@ -98,6 +98,10 @@ export class MdTooltip {
/** Shows the tooltip */
show(): void {
if (!this._message || !this._message.trim()) {
return;
}
if (!this._tooltipInstance) {
this._createTooltip();
}