Skip to content

Commit

Permalink
Added unit test to check that tooltips is not showed when leave event…
Browse files Browse the repository at this point in the history
… is triggered before show delay has expired AND the hide delay is set to 0
  • Loading branch information
jorgenfb committed May 20, 2012
1 parent e9a7d26 commit e388a5e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
1 change: 0 additions & 1 deletion js/bootstrap-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
if (this.timeout) clearTimeout(this.timeout)
if (!self.options.delay || !self.options.delay.hide) return self.hide()

clearTimeout(this.timeout)
self.hoverState = 'out'
this.timeout = setTimeout(function() {
if (self.hoverState == 'out') self.hide()
Expand Down
21 changes: 20 additions & 1 deletion js/tests/unit/bootstrap-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,25 @@ $(function () {
}, 100)
})

test("should not show tooltip if leave event occurs before delay expires, even if hide delay is 0", function () {
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
.appendTo('#qunit-fixture')
.tooltip({ delay: { show: 200, hide: 0} })

stop()

tooltip.trigger('mouseenter')

setTimeout(function () {
ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
tooltip.trigger('mouseout')
setTimeout(function () {
ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
start()
}, 200)
}, 100)
})

test("should not show tooltip if leave event occurs before delay expires", function () {
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
.appendTo('#qunit-fixture')
Expand Down Expand Up @@ -133,4 +152,4 @@ $(function () {
ok($.fn.tooltip.Constructor.prototype.isHTML($('<div></div>')), 'correctly detected html')
})

})
})

0 comments on commit e388a5e

Please sign in to comment.