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', () => {
7474 expect ( tooltipDirective . _tooltipInstance ) . toBeNull ( ) ;
7575 } ) ) ;
7676
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+
77101 it ( 'should not follow through with hide if show is called after' , fakeAsync ( ( ) => {
78102 tooltipDirective . show ( ) ;
79103 expect ( tooltipDirective . _isTooltipVisible ( ) ) . toBe ( true ) ;
Original file line number Diff line number Diff line change @@ -98,6 +98,10 @@ export class MdTooltip {
9898
9999 /** Shows the tooltip */
100100 show ( ) : void {
101+ if ( ! this . _message || ! this . _message . trim ( ) ) {
102+ return ;
103+ }
104+
101105 if ( ! this . _tooltipInstance ) {
102106 this . _createTooltip ( ) ;
103107 }
You can’t perform that action at this time.
0 commit comments