mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(tooltip): don't show tooltip if message is empty or not present (#2081)
Closes #2078
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -98,6 +98,10 @@ export class MdTooltip {
|
||||
|
||||
/** Shows the tooltip */
|
||||
show(): void {
|
||||
if (!this._message || !this._message.trim()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._tooltipInstance) {
|
||||
this._createTooltip();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user