@@ -20,6 +20,11 @@ export function mouseover(target) {
2020 fire ( target , 'mouseover' ) ;
2121}
2222
23+ function getTooltipText ( ) {
24+ const overlay = document . querySelector ( 'vaadin-tooltip-overlay:not([hidden])' ) ;
25+ return overlay && overlay . textContent ;
26+ }
27+
2328describe ( 'menu-bar with tooltip' , ( ) => {
2429 let menuBar , tooltip , buttons ;
2530
@@ -30,13 +35,14 @@ describe('menu-bar with tooltip', () => {
3035 </vaadin-menu-bar>
3136 ` ) ;
3237 menuBar . items = [
33- { text : 'Edit' } ,
38+ { text : 'Edit' , tooltip : 'Edit tooltip' } ,
3439 {
3540 text : 'Share' ,
3641 children : [ { text : 'By email' } ] ,
3742 } ,
3843 {
3944 text : 'Move' ,
45+ tooltip : 'Move tooltip' ,
4046 children : [ { text : 'To folder' } ] ,
4147 } ,
4248 ] ;
@@ -45,7 +51,6 @@ describe('menu-bar with tooltip', () => {
4551 buttons = menuBar . _buttons ;
4652
4753 tooltip = menuBar . querySelector ( 'vaadin-tooltip' ) ;
48- tooltip . generator = ( { item } ) => item && `${ item . text } tooltip` ;
4954 } ) ;
5055
5156 it ( 'should set manual on the tooltip to true' , ( ) => {
@@ -57,6 +62,16 @@ describe('menu-bar with tooltip', () => {
5762 expect ( tooltip . opened ) . to . be . true ;
5863 } ) ;
5964
65+ it ( 'should use the tooltip property of an item as tooltip' , ( ) => {
66+ mouseover ( buttons [ 0 ] ) ;
67+ expect ( getTooltipText ( ) ) . to . equal ( 'Edit tooltip' ) ;
68+ } ) ;
69+
70+ it ( 'should not show tooltip for an item which has no tooltip' , ( ) => {
71+ mouseover ( buttons [ 1 ] ) ;
72+ expect ( getTooltipText ( ) ) . not . to . be . ok ;
73+ } ) ;
74+
6075 it ( 'should not show tooltip on another parent menu button mouseover when open' , async ( ) => {
6176 mouseover ( buttons [ 1 ] ) ;
6277 buttons [ 1 ] . click ( ) ;
@@ -179,6 +194,12 @@ describe('menu-bar with tooltip', () => {
179194 expect ( spyOpened . called ) . to . be . false ;
180195 } ) ;
181196
197+ it ( 'should not override a custom generator' , ( ) => {
198+ tooltip . generator = ( ) => 'Custom tooltip' ;
199+ mouseover ( buttons [ 0 ] ) ;
200+ expect ( getTooltipText ( ) ) . to . equal ( 'Custom tooltip' ) ;
201+ } ) ;
202+
182203 describe ( 'overflow button' , ( ) => {
183204 beforeEach ( async ( ) => {
184205 // Reduce the width by the width of the last visible button
0 commit comments