aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit/bootstrap-tooltip.js
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2012-04-24 02:21:45 -0700
committerJacob Thornton <[email protected]>2012-04-24 02:21:45 -0700
commite659dc7e1be2e09cec34703dce8c737496e3504e (patch)
treebe3caed12a3de1218e1fd548f2564302e6c8193a /js/tests/unit/bootstrap-tooltip.js
parent6506ede6323ee60d4d7f8171937d92141a64e09e (diff)
parent839ef3a030b355d0f0c35d6c9e42ecba8b072036 (diff)
downloadbootstrap-e659dc7e1be2e09cec34703dce8c737496e3504e.tar.xz
bootstrap-e659dc7e1be2e09cec34703dce8c737496e3504e.zip
Merge branch '2.0.3-wip'
Conflicts: Makefile docs/assets/js/bootstrap.js docs/assets/js/bootstrap.min.js
Diffstat (limited to 'js/tests/unit/bootstrap-tooltip.js')
-rw-r--r--js/tests/unit/bootstrap-tooltip.js74
1 files changed, 74 insertions, 0 deletions
diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js
index 8543162c6..63f4f0b07 100644
--- a/js/tests/unit/bootstrap-tooltip.js
+++ b/js/tests/unit/bootstrap-tooltip.js
@@ -59,4 +59,78 @@ $(function () {
ok(!$(".tooltip").length, 'tooltip removed')
})
+ 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')
+ .tooltip({ delay: 200 })
+
+ stop()
+
+ tooltip.trigger('mouseenter')
+
+ setTimeout(function () {
+ ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
+ tooltip.trigger('mouseout')
+ setTimeout(function () {
+ ok(!$(".tooltip").hasClass('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')
+ .tooltip({ delay: 100 })
+ stop()
+ tooltip.trigger('mouseenter')
+ setTimeout(function () {
+ ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
+ tooltip.trigger('mouseout')
+ setTimeout(function () {
+ ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
+ start()
+ }, 100)
+ }, 50)
+ })
+
+ test("should show tooltip if leave event hasn't occured before delay expires", function () {
+ var tooltip = $('<a href="#" rel="tooltip" title="Another tooltip"></a>')
+ .appendTo('#qunit-fixture')
+ .tooltip({ delay: 200 })
+ stop()
+ tooltip.trigger('mouseenter')
+ setTimeout(function () {
+ ok(!$(".tooltip").hasClass('fade in'), 'tooltip is not faded in')
+ setTimeout(function () {
+ ok(!$(".tooltip").hasClass('fade in'), 'tooltip has faded in')
+ start()
+ }, 200)
+ }, 100)
+ })
+
+ test("should detect if title string is html or text: foo", function () {
+ ok(!$.fn.tooltip.Constructor.prototype.isHTML('foo'), 'correctly detected html')
+ })
+
+ test("should detect if title string is html or text: &amp;lt;foo&amp;gt;", function () {
+ ok(!$.fn.tooltip.Constructor.prototype.isHTML('&lt;foo&gt;'), 'correctly detected html')
+ })
+
+ test("should detect if title string is html or text: &lt;div>foo&lt;/div>", function () {
+ ok($.fn.tooltip.Constructor.prototype.isHTML('<div>foo</div>'), 'correctly detected html')
+ })
+
+ test("should detect if title string is html or text: asdfa&lt;div>foo&lt;/div>asdfasdf", function () {
+ ok($.fn.tooltip.Constructor.prototype.isHTML('asdfa<div>foo</div>asdfasdf'), 'correctly detected html')
+ })
+
+ test("should detect if title string is html or text: document.createElement('div')", function () {
+ ok($.fn.tooltip.Constructor.prototype.isHTML(document.createElement('div')), 'correctly detected html')
+ })
+
+ test("should detect if title string is html or text: $('&lt;div />)", function () {
+ ok($.fn.tooltip.Constructor.prototype.isHTML($('<div></div>')), 'correctly detected html')
+ })
+
}) \ No newline at end of file