]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Add test for popover. 13165/head
authorStefan Neculai <stefan.neculai@gmail.com>
Mon, 24 Mar 2014 17:49:06 +0000 (19:49 +0200)
committerStefan Neculai <stefan.neculai@gmail.com>
Mon, 24 Mar 2014 17:49:06 +0000 (19:49 +0200)
js/tests/unit/popover.js

index c08b6d8ef23170024fe01bd2d896a49c8484111f..24f2f6f03ea1575409415ba44fe3bc24f0a40726 100644 (file)
@@ -61,6 +61,35 @@ $(function () {
     $('#qunit-fixture').empty()
   })
 
+  test('should not duplicate HTML object', function () {
+    $.support.transition = false
+
+    $div = $('<div>').html('loves writing tests (╯°□°)╯︵ ┻━┻')
+
+    var popover = $('<a href="#">@fat</a>')
+      .appendTo('#qunit-fixture')
+      .popover({
+        content: function () {
+          return $div
+        }
+      })
+
+    popover.popover('show')
+    ok($('.popover').length, 'popover was inserted')
+    equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
+
+    popover.popover('hide')
+    ok(!$('.popover').length, 'popover was removed')
+
+    popover.popover('show')
+    ok($('.popover').length, 'popover was inserted')
+    equal($('.popover .popover-content').html(), $div, 'content correctly inserted')
+
+    popover.popover('hide')
+    ok(!$('.popover').length, 'popover was removed')
+    $('#qunit-fixture').empty()
+  })
+
   test('should get title and content from attributes', function () {
     $.support.transition = false
     var popover = $('<a href="#" title="@mdo" data-content="loves data attributes (づ。◕‿‿◕。)づ ︵ ┻━┻" >@mdo</a>')