diff options
author | Scott Gonyea <me@sgonyea.com> | 2014-08-05 00:03:11 +0400 |
---|---|---|
committer | Scott Gonyea <me@sgonyea.com> | 2014-08-29 04:17:50 +0400 |
commit | aac0e16452301a4735a668dc228b6b084b2d63d0 (patch) | |
tree | 2b5f01ea91a96a9320d2ea4e271adeb57cedc165 /js/tests/unit/tooltip.js | |
parent | 9096c2002123a6dafdf0c3d9df5d069c968d738e (diff) |
Fix hover-tooltip flickering when mouse re-enters
- is(':visible') seems to be the only reliable check, without a refactoring of how hoverState is used
- tests need improvement
Diffstat (limited to 'js/tests/unit/tooltip.js')
-rw-r--r-- | js/tests/unit/tooltip.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/js/tests/unit/tooltip.js b/js/tests/unit/tooltip.js index 7896c2c969..c0c6284852 100644 --- a/js/tests/unit/tooltip.js +++ b/js/tests/unit/tooltip.js @@ -775,4 +775,65 @@ $(function () { $circle.bootstrapTooltip('show') }) + test('should not reload the tooltip on subsequent mouseenter events', function () { + var titleHtml = function () { + var uid = $.fn.bootstrapTooltip.Constructor.prototype.getUID('tooltip') + return '<p id="tt-content">' + uid + '</p><p>' + uid + '</p><p>' + uid + '</p>' + } + + var $tooltip = $('<span id="tt-outer" rel="tooltip" data-trigger="hover" data-placement="top">some text</span>') + .appendTo('#qunit-fixture') + + $tooltip.bootstrapTooltip({ + html: true, + animation: false, + trigger: 'hover', + delay: { show: 0, hide: 500 }, + container: $tooltip, + title: titleHtml + }) + + $('#tt-outer').trigger('mouseenter') + + var currentUid = $('#tt-content').text() + + $('#tt-content').trigger('mouseenter') + equal(currentUid, $('#tt-content').text()) + }) + + test('should not reload the tooltip if the mouse leaves and re-enters before hiding', function () { + var titleHtml = function () { + var uid = $.fn.bootstrapTooltip.Constructor.prototype.getUID('tooltip') + return '<p id="tt-content">' + uid + '</p><p>' + uid + '</p><p>' + uid + '</p>' + } + + var $tooltip = $('<span id="tt-outer" rel="tooltip" data-trigger="hover" data-placement="top">some text</span>') + .appendTo('#qunit-fixture') + + $tooltip.bootstrapTooltip({ + html: true, + animation: false, + trigger: 'hover', + delay: { show: 0, hide: 500 }, + container: $tooltip, + title: titleHtml + }) + + var obj = $tooltip.data('bs.tooltip') + + $('#tt-outer').trigger('mouseenter') + + var currentUid = $('#tt-content').text() + + $('#tt-outer').trigger('mouseleave') + equal(currentUid, $('#tt-content').text()) + + ok(obj.hoverState == 'out', 'the tooltip hoverState should be set to "out"') + + $('#tt-content').trigger('mouseenter') + ok(obj.hoverState == 'in', 'the tooltip hoverState should be set to "in"') + + equal(currentUid, $('#tt-content').text()) + }) + }) |