]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Added unit test to check that tooltips is not showed when leave event is triggered... 3550/head 3654/head
authorJørgen Borgesen <joergen.borgesen@gmail.com>
Sun, 20 May 2012 17:59:53 +0000 (19:59 +0200)
committerJørgen Borgesen <joergen.borgesen@gmail.com>
Sun, 20 May 2012 17:59:53 +0000 (19:59 +0200)
js/bootstrap-tooltip.js
js/tests/unit/bootstrap-tooltip.js

index 4c2a2a328d1ab7c0de31122241eb9db35eb9542a..6ff2b47086529d169bc7c3c6a39d9844d3b5141a 100644 (file)
@@ -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()
index 63f4f0b07cb6b376d05b21ba5df4fdd8721ca54b..c25093420da1abbf6f959a6ac53281179aeefd45 100644 (file)
@@ -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')
@@ -133,4 +152,4 @@ $(function () {
         ok($.fn.tooltip.Constructor.prototype.isHTML($('<div></div>')), 'correctly detected html')
       })
 
-})
\ No newline at end of file
+})