From dcf9aabc44d4ca7cd544b726d4eee15ef1cd35a5 Mon Sep 17 00:00:00 2001
From: Jacob Thornton <jacobthornton@gmail.com>
Date: Sun, 11 Sep 2011 22:58:51 -0700
Subject: [PATCH] get all spec passing again

---
 js/tests/index.html                |  2 +-
 js/tests/unit/bootstrap-modal.js   | 39 ++++++++++++++++--------------
 js/tests/unit/bootstrap-popover.js | 27 ++++++++++++---------
 js/tests/unit/bootstrap-twipsy.js  | 16 ++++++------
 4 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/js/tests/index.html b/js/tests/index.html
index 4f904b9c0c..2ca94102ad 100644
--- a/js/tests/index.html
+++ b/js/tests/index.html
@@ -10,7 +10,7 @@
   <link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" />
   <script src="vendor/qunit.js"></script>
 
-  <!-- plugin sources -->
+  <!--  plugin sources -->
   <script src="../../js/bootstrap-alerts.js"></script>
   <script src="../../js/bootstrap-dropdown.js"></script>
   <script src="../../js/bootstrap-modal.js"></script>
diff --git a/js/tests/unit/bootstrap-modal.js b/js/tests/unit/bootstrap-modal.js
index 513d287804..4bbb3313cc 100644
--- a/js/tests/unit/bootstrap-modal.js
+++ b/js/tests/unit/bootstrap-modal.js
@@ -16,36 +16,37 @@ $(function () {
         ok($.fn.modal.defaults, 'default object exposed')
       })
 
-      test("should insert into dom when modal:show event is called", function () {
+      test("should insert into dom when show method is called", function () {
         stop()
         $.support.transition = false
         var div = $("<div id='modal-test'></div>")
         div
           .modal()
-          .trigger("modal:show")
-          .bind("modal:shown", function () {
+          .modal("show")
+          .bind("shown", function () {
             ok($('#modal-test').length, 'modal insterted into dom')
             start()
             div.remove()
           })
       })
 
-      test("should remove from dom when modal:hide is called", function () {
+      test("should hide modal when hide is called", function () {
         stop()
         $.support.transition = false
         var div = $("<div id='modal-test'></div>")
         div
           .modal()
-          .trigger("modal:show")
-          .bind("modal:shown", function () {
+          .bind("shown", function () {
+            ok($('#modal-test').is(":visible"), 'modal visible')
             ok($('#modal-test').length, 'modal insterted into dom')
-            div.trigger("modal:hide")
+            div.modal("hide")
           })
-          .bind("modal:hidden", function() {
-            ok(!$('#modal-test').length, 'modal removed from dom')
+          .bind("hidden", function() {
+            ok(!$('#modal-test').is(":visible"), 'modal hidden')
             start()
             div.remove()
           })
+          .modal("show")
       })
 
       test("should toggle when toggle is called", function () {
@@ -54,16 +55,17 @@ $(function () {
         var div = $("<div id='modal-test'></div>")
         div
           .modal()
-          .trigger("modal:toggle")
-          .bind("modal:shown", function () {
+          .bind("shown", function () {
+            ok($('#modal-test').is(":visible"), 'modal visible')
             ok($('#modal-test').length, 'modal insterted into dom')
-            div.trigger("modal:toggle")
+            div.modal("toggle")
           })
-          .bind("modal:hidden", function() {
-            ok(!$('#modal-test').length, 'modal removed from dom')
+          .bind("hidden", function() {
+            ok(!$('#modal-test').is(":visible"), 'modal hidden')
             start()
             div.remove()
           })
+          .modal("toggle")
       })
 
       test("should remove from dom when click .close", function () {
@@ -72,15 +74,16 @@ $(function () {
         var div = $("<div id='modal-test'><span class='close'></span></div>")
         div
           .modal()
-          .trigger("modal:toggle")
-          .bind("modal:shown", function () {
+          .bind("shown", function () {
+            ok($('#modal-test').is(":visible"), 'modal visible')
             ok($('#modal-test').length, 'modal insterted into dom')
             div.find('.close').click()
           })
-          .bind("modal:hidden", function() {
-            ok(!$('#modal-test').length, 'modal removed from dom')
+          .bind("hidden", function() {
+            ok(!$('#modal-test').is(":visible"), 'modal hidden')
             start()
             div.remove()
           })
+          .modal("toggle")
       })
 })
\ No newline at end of file
diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js
index 42ecd70ae5..3e13d2fd20 100644
--- a/js/tests/unit/bootstrap-popover.js
+++ b/js/tests/unit/bootstrap-popover.js
@@ -14,20 +14,20 @@ $(function () {
 
       test("should render popover element", function () {
         $.support.transition = false
-        var popover = $('<a href="#" data-title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
+        var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
           .appendTo('#qunit-runoff')
           .popover()
-          .trigger('popover:show')
+          .popover('show')
 
         ok($('.popover').length, 'popover was inserted')
-        popover.trigger('popover:hide')
+        popover.popover('hide')
         ok(!$(".popover").length, 'popover removed')
         $('#qunit-runoff').empty()
       })
 
       test("should store popover instance in popover data object", function () {
         $.support.transition = false
-        var popover = $('<a href="#" data-title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
+        var popover = $('<a href="#" title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
           .popover()
 
         ok(!!popover.data('popover'), 'popover instance exists')
@@ -38,32 +38,37 @@ $(function () {
         var popover = $('<a href="#">@fat</a>')
           .appendTo('#qunit-runoff')
           .popover({
-            title: '@fat'
-          , content: 'loves writing tests (╯°□°)╯︵ ┻━┻'
+            title: function () {
+              return '@fat'
+            }
+          , content: function () {
+              return 'loves writing tests (╯°□°)╯︵ ┻━┻'
+            }
           })
-          .trigger('popover:show')
+
+        popover.popover('show')
 
         ok($('.popover').length, 'popover was inserted')
         equals($('.popover .title').text(), '@fat', 'title correctly inserted')
         equals($('.popover .content').text(), 'loves writing tests (╯°□°)╯︵ ┻━┻', 'content correctly inserted')
 
-        popover.trigger('popover:hide')
+        popover.popover('hide')
         ok(!$('.popover').length, 'popover was removed')
         $('#qunit-runoff').empty()
       })
 
       test("should get title and content from attributes", function () {
         $.support.transition = false
-        var popover = $('<a href="#" data-title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
+        var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')
           .appendTo('#qunit-runoff')
           .popover()
-          .trigger('popover:show')
+          .popover('show')
 
         ok($('.popover').length, 'popover was inserted')
         equals($('.popover .title').text(), '@mdo', 'title correctly inserted')
         equals($('.popover .content').text(), "loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻", 'content correctly inserted')
 
-        popover.trigger('popover:hide')
+        popover.popover('hide')
         ok(!$('.popover').length, 'popover was removed')
         $('#qunit-runoff').empty()
       })
diff --git a/js/tests/unit/bootstrap-twipsy.js b/js/tests/unit/bootstrap-twipsy.js
index 05de7e9380..04000696ae 100644
--- a/js/tests/unit/bootstrap-twipsy.js
+++ b/js/tests/unit/bootstrap-twipsy.js
@@ -31,10 +31,10 @@ $(function () {
         var twipsy = $('<a href="#" rel="twipsy" title="Another twipsy"></a>')
           .appendTo('#qunit-runoff')
           .twipsy({placement: 'below'})
-          .trigger('twipsy:show')
+          .twipsy('show')
 
         ok($(".twipsy").hasClass('fade below in'), 'has correct classes applied')
-        twipsy.trigger('twipsy:hide')
+        twipsy.twipsy('hide')
         ok(!$(".twipsy").length, 'twipsy removed')
         $('#qunit-runoff').empty()
       })
@@ -44,10 +44,10 @@ $(function () {
         var twipsy = $('<a href="#" rel="twipsy"></a>')
           .appendTo('#qunit-runoff')
           .twipsy({fallback: '@fat'})
-          .trigger('twipsy:show')
+          .twipsy('show')
 
         equals($(".twipsy").text(), "@fat", 'has correct default text')
-        twipsy.trigger('twipsy:hide')
+        twipsy.twipsy('hide')
         ok(!$(".twipsy").length, 'twipsy removed')
         $('#qunit-runoff').empty()
       })
@@ -57,10 +57,10 @@ $(function () {
         var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
           .appendTo('#qunit-runoff')
           .twipsy()
-          .trigger('twipsy:show')
+          .twipsy('show')
 
         ok(!$('.twipsy b').length, 'b tag was not inserted')
-        twipsy.trigger('twipsy:hide')
+        twipsy.twipsy('hide')
         ok(!$(".twipsy").length, 'twipsy removed')
         $('#qunit-runoff').empty()
       })
@@ -70,10 +70,10 @@ $(function () {
         var twipsy = $('<a href="#" rel="twipsy" title="<b>@fat</b>"></a>')
           .appendTo('#qunit-runoff')
           .twipsy({html: true})
-          .trigger('twipsy:show')
+          .twipsy('show')
 
         ok($('.twipsy b').length, 'b tag was inserted')
-        twipsy.trigger('twipsy:hide')
+        twipsy.twipsy('hide')
         ok(!$(".twipsy").length, 'twipsy removed')
         $('#qunit-runoff').empty()
       })
-- 
GitLab