diff options
| author | fat <[email protected]> | 2013-02-05 22:10:41 -0800 |
|---|---|---|
| committer | fat <[email protected]> | 2013-02-05 22:10:41 -0800 |
| commit | 5e4db94c240c5ac2af18bbf4238358a043ad4037 (patch) | |
| tree | 4684990e086ba661c4a8fbc406c80255ccf10b9e /js/tests/unit | |
| parent | a4b31d39a26bf493d60d4aaadddd19996966e43c (diff) | |
| parent | ee71fb492ffc664627436431c5f7b71d2107a526 (diff) | |
| download | bootstrap-5e4db94c240c5ac2af18bbf4238358a043ad4037.tar.xz bootstrap-5e4db94c240c5ac2af18bbf4238358a043ad4037.zip | |
Merge branch '2.3.0-wip' of git://github.com/ghusse/bootstrap into ghusse-2.3.0-wip
Diffstat (limited to 'js/tests/unit')
| -rw-r--r-- | js/tests/unit/bootstrap-tooltip.css | 13 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-tooltip.js | 61 |
2 files changed, 74 insertions, 0 deletions
diff --git a/js/tests/unit/bootstrap-tooltip.css b/js/tests/unit/bootstrap-tooltip.css new file mode 100644 index 000000000..8614e60d7 --- /dev/null +++ b/js/tests/unit/bootstrap-tooltip.css @@ -0,0 +1,13 @@ + + +.tooltip{ + position: absolute; +} + +.tooltip-inner{ + max-width: 200px; +} + +.tooltip.top .tooltip-arrow{ + position: absolute; +}
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js index ef21bd96b..dc4c19bcf 100644 --- a/js/tests/unit/bootstrap-tooltip.js +++ b/js/tests/unit/bootstrap-tooltip.js @@ -251,4 +251,65 @@ $(function () { ok(!$("#qunit-fixture > .tooltip").length, 'not found in parent') tooltip.tooltip('hide') }) + + test("should place tooltip inside window", function(){ + var container = $("<div />").appendTo("body") + .css({position: "absolute", width: 200, height: 200, bottom: 0, left: 0}) + , tooltip = $("<a href='#' title='Very very very very very very very very long tooltip'>Hover me</a>") + .css({position: "absolute", top:0, left: 0}) + .appendTo(container) + .tooltip({placement: "top", animate: false}) + .tooltip("show") + + stop() + + setTimeout(function(){ + ok($(".tooltip").offset().left >= 0) + + start() + container.remove() + }, 100) + }) + + test("should place tooltip on top of element", function(){ + var container = $("<div />").appendTo("body") + .css({position: "absolute", bottom: 0, left: 0, textAlign: "right", width: 300, height: 300}) + , p = $("<p style='margin-top:200px' />").appendTo(container) + , tooltiped = $("<a href='#' title='very very very very very very very long tooltip'>Hover me</a>") + .css({marginTop: 200}) + .appendTo(p) + .tooltip({placement: "top", animate: false}) + .tooltip("show") + + stop() + + setTimeout(function(){ + var tooltip = container.find(".tooltip") + + start() + ok(tooltip.offset().top + tooltip.outerHeight() <= tooltiped.offset().top) + container.remove() + }, 100) + }) + + test("arrow should point to element", function(){ + var container = $("<div />").appendTo("body") + .css({position: "absolute", bottom: 0, left: 0, textAlign: "right", width: 300, height: 300}) + , p = $("<p style='margin-top:200px' />").appendTo(container) + , tooltiped = $("<a href='#' title='very very very very very very very long tooltip'>Hover me</a>") + .css({marginTop: 200}) + .appendTo(p) + .tooltip({placement: "top", animate: false}) + .tooltip("show") + + stop() + + setTimeout(function(){ + var arrow = container.find(".tooltip-arrow") + + start() + ok(Math.abs(arrow.offset().left - tooltiped.offset().left - tooltiped.outerWidth()/2) <= 1) + container.remove() + }, 100) + }) }) |
