Skip to content

Commit e388a5e

Browse files
committed
Added unit test to check that tooltips is not showed when leave event is triggered before show delay has expired AND the hide delay is set to 0
1 parent e9a7d26 commit e388a5e

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

js/bootstrap-tooltip.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787
if (this.timeout) clearTimeout(this.timeout)
8888
if (!self.options.delay || !self.options.delay.hide) return self.hide()
8989

90-
clearTimeout(this.timeout)
9190
self.hoverState = 'out'
9291
this.timeout = setTimeout(function() {
9392
if (self.hoverState == 'out') self.hide()

js/tests/unit/bootstrap-tooltip.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,25 @@ $(function () {
7878
}, 100)
7979
})
8080

81+
test("should not show tooltip if leave event occurs before delay expires, even if hide delay is 0", function () {
82+
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
83+
.appendTo('#qunit-fixture')
84+
.tooltip({ delay: { show: 200, hide: 0} })
85+
86+
stop()
87+
88+
tooltip.trigger('mouseenter')
89+
90+
setTimeout(function () {
91+
ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
92+
tooltip.trigger('mouseout')
93+
setTimeout(function () {
94+
ok(!$(".tooltip").is('.fade.in'), 'tooltip is not faded in')
95+
start()
96+
}, 200)
97+
}, 100)
98+
})
99+
81100
test("should not show tooltip if leave event occurs before delay expires", function () {
82101
var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
83102
.appendTo('#qunit-fixture')
@@ -133,4 +152,4 @@ $(function () {
133152
ok($.fn.tooltip.Constructor.prototype.isHTML($('<div></div>')), 'correctly detected html')
134153
})
135154

136-
})
155+
})

0 commit comments

Comments
 (0)