File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,30 @@ describe('MdTooltip', () => {
74
74
expect ( tooltipDirective . _tooltipInstance ) . toBeNull ( ) ;
75
75
} ) ) ;
76
76
77
+ it ( 'should not show tooltip if message is not present or empty' , fakeAsync ( ( ) => {
78
+ expect ( tooltipDirective . _tooltipInstance ) . toBeUndefined ( ) ;
79
+
80
+ tooltipDirective . message = undefined ;
81
+ fixture . detectChanges ( ) ;
82
+ tooltipDirective . show ( ) ;
83
+ expect ( tooltipDirective . _tooltipInstance ) . toBeUndefined ( ) ;
84
+
85
+ tooltipDirective . message = null ;
86
+ fixture . detectChanges ( ) ;
87
+ tooltipDirective . show ( ) ;
88
+ expect ( tooltipDirective . _tooltipInstance ) . toBeUndefined ( ) ;
89
+
90
+ tooltipDirective . message = '' ;
91
+ fixture . detectChanges ( ) ;
92
+ tooltipDirective . show ( ) ;
93
+ expect ( tooltipDirective . _tooltipInstance ) . toBeUndefined ( ) ;
94
+
95
+ tooltipDirective . message = ' ' ;
96
+ fixture . detectChanges ( ) ;
97
+ tooltipDirective . show ( ) ;
98
+ expect ( tooltipDirective . _tooltipInstance ) . toBeUndefined ( ) ;
99
+ } ) ) ;
100
+
77
101
it ( 'should not follow through with hide if show is called after' , fakeAsync ( ( ) => {
78
102
tooltipDirective . show ( ) ;
79
103
expect ( tooltipDirective . _isTooltipVisible ( ) ) . toBe ( true ) ;
Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ export class MdTooltip {
98
98
99
99
/** Shows the tooltip */
100
100
show ( ) : void {
101
+ if ( ! this . _message || ! this . _message . trim ( ) ) {
102
+ return ;
103
+ }
104
+
101
105
if ( ! this . _tooltipInstance ) {
102
106
this . _createTooltip ( ) ;
103
107
}
You can’t perform that action at this time.
0 commit comments