aboutsummaryrefslogtreecommitdiff
path: root/js/tests
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2011-09-10 13:17:08 -0700
committerJacob Thornton <[email protected]>2011-09-10 13:17:08 -0700
commit1041977d0acedfcbd0d2a0d4a007496ccad10991 (patch)
tree37908393bad789cb0b301b4d71f7ec6dc6157d80 /js/tests
parent48aa209348c47df65f4edb0d8a36ccaac357eb0a (diff)
downloadbootstrap-1041977d0acedfcbd0d2a0d4a007496ccad10991.tar.xz
bootstrap-1041977d0acedfcbd0d2a0d4a007496ccad10991.zip
finish up rounding out tests for all js plugins
Diffstat (limited to 'js/tests')
-rw-r--r--js/tests/unit/bootstrap-popover.js84
1 files changed, 71 insertions, 13 deletions
diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js
index e81e349b1..42ecd70ae 100644
--- a/js/tests/unit/bootstrap-popover.js
+++ b/js/tests/unit/bootstrap-popover.js
@@ -1,13 +1,71 @@
-// $(function () {
-//
-// module("bootstrap-popover")
-//
-// test("should be defined on jquery object", function () {
-// ok($(document.body).popover, 'popover method is defined')
-// })
-//
-// test("should return element", function () {
-// ok($(document.body).popover()[0] == document.body, 'document.body returned')
-// })
-//
-// }) \ No newline at end of file
+$(function () {
+
+ module("bootstrap-popover")
+
+ test("should be defined on jquery object", function () {
+ var div = $('<div></div>')
+ ok(div.popover, 'popover method is defined')
+ })
+
+ test("should return element", function () {
+ var div = $('<div></div>')
+ ok(div.popover() == div, 'document.body returned')
+ })
+
+ test("should render popover element", function () {
+ $.support.transition = false
+ var popover = $('<a href="#" data-title="mdo" data-content="http://twitter.com/mdo">@mdo</a>')
+ .appendTo('#qunit-runoff')
+ .popover()
+ .trigger('popover:show')
+
+ ok($('.popover').length, 'popover was inserted')
+ popover.trigger('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>')
+ .popover()
+
+ ok(!!popover.data('popover'), 'popover instance exists')
+ })
+
+ test("should get title and content from options", function () {
+ $.support.transition = false
+ var popover = $('<a href="#">@fat</a>')
+ .appendTo('#qunit-runoff')
+ .popover({
+ title: '@fat'
+ , content: 'loves writing tests (╯°□°)╯︵ ┻━┻'
+ })
+ .trigger('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')
+ 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>')
+ .appendTo('#qunit-runoff')
+ .popover()
+ .trigger('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')
+ ok(!$('.popover').length, 'popover was removed')
+ $('#qunit-runoff').empty()
+ })
+
+}) \ No newline at end of file