@@ -398,4 +398,92 @@ describe('Tooltip', () => {
398398 wrapper . detach ( ) ;
399399 } ) ;
400400 } ) ;
401+
402+ describe ( 'autohide' , ( ) => {
403+ it ( 'should keep tooltip around when false and onmouseleave from tooltip content' , ( ) => {
404+ spyOn ( Tooltip . prototype , 'toggle' ) . and . callThrough ( ) ;
405+ isOpen = true ;
406+ const wrapper = mount (
407+ < Tooltip target = "target" autohide = { false } isOpen = { isOpen } toggle = { toggle } delay = { 200 } >
408+ Tooltip Content
409+ </ Tooltip > ,
410+ { attachTo : container }
411+ ) ;
412+ const instance = wrapper . instance ( ) ;
413+
414+ expect ( isOpen ) . toBe ( true ) ;
415+ expect ( Tooltip . prototype . toggle ) . not . toHaveBeenCalled ( ) ;
416+
417+ instance . onMouseLeaveTooltipContent ( ) ;
418+ jasmine . clock ( ) . tick ( 100 ) ;
419+ expect ( Tooltip . prototype . toggle ) . not . toHaveBeenCalled ( ) ;
420+ jasmine . clock ( ) . tick ( 200 ) ;
421+ expect ( Tooltip . prototype . toggle ) . toHaveBeenCalled ( ) ;
422+
423+ wrapper . detach ( ) ;
424+ } ) ;
425+
426+ it ( 'clears showTimeout in onMouseLeaveTooltipContent' , ( ) => {
427+ spyOn ( Tooltip . prototype , 'toggle' ) . and . callThrough ( ) ;
428+ isOpen = true ;
429+ const wrapper = mount (
430+ < Tooltip target = "target" autohide = { false } isOpen = { isOpen } toggle = { toggle } delay = { 200 } >
431+ Tooltip Content
432+ </ Tooltip > ,
433+ { attachTo : container }
434+ ) ;
435+ const instance = wrapper . instance ( ) ;
436+
437+ instance . onMouseOverTooltip ( ) ;
438+ expect ( instance . _showTimeout ) . toBeTruthy ( ) ;
439+ instance . onMouseLeaveTooltipContent ( ) ;
440+ jasmine . clock ( ) . tick ( 300 ) ;
441+ expect ( instance . _showTimeout ) . toBeFalsy ( ) ;
442+ wrapper . detach ( ) ;
443+ } ) ;
444+
445+ it ( 'clears hide timeout in onMouseOverTooltipContent' , ( ) => {
446+ spyOn ( Tooltip . prototype , 'toggle' ) . and . callThrough ( ) ;
447+ isOpen = true ;
448+ const wrapper = mount (
449+ < Tooltip target = "target" autohide = { false } isOpen = { isOpen } toggle = { toggle } delay = { 200 } >
450+ Tooltip Content
451+ </ Tooltip > ,
452+ { attachTo : container }
453+ ) ;
454+ const instance = wrapper . instance ( ) ;
455+
456+ expect ( isOpen ) . toBe ( true ) ;
457+ expect ( Tooltip . prototype . toggle ) . not . toHaveBeenCalled ( ) ;
458+ instance . onMouseLeaveTooltipContent ( ) ;
459+ jasmine . clock ( ) . tick ( 100 ) ;
460+ expect ( instance . _hideTimeout ) . toBeTruthy ( ) ;
461+ instance . onMouseOverTooltipContent ( ) ;
462+ expect ( instance . _hideTimeout ) . toBeFalsy ( ) ;
463+ instance . onMouseOverTooltipContent ( ) ;
464+ wrapper . detach ( ) ;
465+ } ) ;
466+
467+ it ( 'should not keep tooltip around when autohide is true and tooltip content is hovered over' , ( ) => {
468+ spyOn ( Tooltip . prototype , 'toggle' ) . and . callThrough ( ) ;
469+ isOpen = true ;
470+ const wrapper = mount (
471+ < Tooltip target = "target" autohide isOpen = { isOpen } toggle = { toggle } delay = { 200 } >
472+ Tooltip Content
473+ </ Tooltip > ,
474+ { attachTo : container }
475+ ) ;
476+ const instance = wrapper . instance ( ) ;
477+ expect ( isOpen ) . toBe ( true ) ;
478+ expect ( Tooltip . prototype . toggle ) . not . toHaveBeenCalled ( ) ;
479+ instance . onMouseLeaveTooltip ( ) ;
480+ jasmine . clock ( ) . tick ( 100 ) ;
481+ instance . onMouseOverTooltipContent ( ) ;
482+ jasmine . clock ( ) . tick ( 200 ) ;
483+ expect ( Tooltip . prototype . toggle ) . toHaveBeenCalled ( ) ;
484+ instance . onMouseLeaveTooltipContent ( ) ;
485+ expect ( instance . _hideTimeout ) . toBeFalsy ( ) ;
486+ wrapper . detach ( ) ;
487+ } ) ;
488+ } ) ;
401489} ) ;
0 commit comments