Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKAWACHI Takashi <kawachi@p-lucky.net>2012-12-14 11:35:11 +0400
committerKAWACHI Takashi <kawachi@p-lucky.net>2012-12-23 09:42:13 +0400
commit7a3a88acc60f7055720b919e281d3c881d05916f (patch)
treeca10fd459d0cd40cb188bcb1d3e5b587377e448f /js/tests/unit/bootstrap-tooltip.js
parent48211ad9f572504cdfa00273a66d701e62ec291d (diff)
Tooltips fires show, shown, hide, hidden events
It is re-worked from #3691.
Diffstat (limited to 'js/tests/unit/bootstrap-tooltip.js')
-rw-r--r--js/tests/unit/bootstrap-tooltip.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js
index c44f75757a..1370ef381e 100644
--- a/js/tests/unit/bootstrap-tooltip.js
+++ b/js/tests/unit/bootstrap-tooltip.js
@@ -66,6 +66,83 @@ $(function () {
ok(!$(".tooltip").length, 'tooltip removed')
})
+ test("should fire show event", function () {
+ stop()
+ var tooltip = $('<div title="tooltip title"></div>')
+ .bind("show", function() {
+ ok(true, "show was called")
+ start()
+ })
+ .tooltip('show')
+ })
+
+ test("should fire shown event", function () {
+ stop()
+ var tooltip = $('<div title="tooltip title"></div>')
+ .bind("shown", function() {
+ ok(true, "shown was called")
+ start()
+ })
+ .tooltip('show')
+ })
+
+ test("should not fire shown event when default prevented", function () {
+ stop()
+ var tooltip = $('<div title="tooltip title"></div>')
+ .bind("show", function(e) {
+ e.preventDefault()
+ ok(true, "show was called")
+ start()
+ })
+ .bind("shown", function() {
+ ok(false, "shown was called")
+ })
+ .tooltip('show')
+ })
+
+ test("should fire hide event", function () {
+ stop()
+ var tooltip = $('<div title="tooltip title"></div>')
+ .bind("shown", function() {
+ $(this).tooltip('hide')
+ })
+ .bind("hide", function() {
+ ok(true, "hide was called")
+ start()
+ })
+ .tooltip('show')
+ })
+
+ test("should fire hidden event", function () {
+ stop()
+ var tooltip = $('<div title="tooltip title"></div>')
+ .bind("shown", function() {
+ $(this).tooltip('hide')
+ })
+ .bind("hidden", function() {
+ ok(true, "hidden was called")
+ start()
+ })
+ .tooltip('show')
+ })
+
+ test("should not fire hidden event when default prevented", function () {
+ stop()
+ var tooltip = $('<div title="tooltip title"></div>')
+ .bind("shown", function() {
+ $(this).tooltip('hide')
+ })
+ .bind("hide", function(e) {
+ e.preventDefault()
+ ok(true, "hide was called")
+ start()
+ })
+ .bind("hidden", function() {
+ ok(false, "hidden was called")
+ })
+ .tooltip('show')
+ })
+
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')