From 929598784f3a2e4f706d5dcd5a41cea207dfd65e Mon Sep 17 00:00:00 2001 From: Guillaume Gautreau Date: Sat, 26 Jan 2013 14:06:58 +0100 Subject: Unit test for replacing tooltip inside window --- js/bootstrap-tooltip.js | 2 +- js/tests/unit/bootstrap-tooltip.js | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js index 0d8a20f568..49c3c6be42 100644 --- a/js/bootstrap-tooltip.js +++ b/js/bootstrap-tooltip.js @@ -190,7 +190,7 @@ if (offset.left < 0){ delta = -offset.left * 2; - offset.left = 0; + offset.left = .1; $tip.offset(offset); actualWidth = $tip[0].offsetWidth; actualHeight = $tip[0].offsetHeight; diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index ef21bd96b4..94f40f339f 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -251,4 +251,22 @@ $(function () { ok(!$("#qunit-fixture > .tooltip").length, 'not found in parent') tooltip.tooltip('hide') }) + + test("should place tooltip inside window", function(){ + $("#qunit-fixture").show(); + var tooltip = $("") + .css({position: "absolute", top:0, left: 0}) + .appendTo("#qunit-fixture") + .tooltip({placement: "top"}) + .tooltip("show"); + + stop(); + + setTimeout(function(){ + ok($(".tooltip").offset().left >= 0); + + start(); + $("#qunit-fixture").hide(); + }, 200) + }); }) -- cgit v1.2.3