aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2011-09-10 22:14:57 -0700
committerJacob Thornton <[email protected]>2011-09-10 22:14:57 -0700
commit64176caa972fdf925fe244cdbf1d53d82da592f4 (patch)
tree413ff6c850a038be203b64526caca958db1487c6 /js/tests/unit
parenta71d5d8e991eee4073d3312743778b1991cfb650 (diff)
downloadbootstrap-64176caa972fdf925fe244cdbf1d53d82da592f4.tar.xz
bootstrap-64176caa972fdf925fe244cdbf1d53d82da592f4.zip
add bootstrap-scrollspy
Diffstat (limited to 'js/tests/unit')
-rw-r--r--js/tests/unit/bootstrap-modal.js68
-rw-r--r--js/tests/unit/bootstrap-scrollspy.js31
2 files changed, 80 insertions, 19 deletions
diff --git a/js/tests/unit/bootstrap-modal.js b/js/tests/unit/bootstrap-modal.js
index cfdf4064d..513d28780 100644
--- a/js/tests/unit/bootstrap-modal.js
+++ b/js/tests/unit/bootstrap-modal.js
@@ -17,40 +17,70 @@ $(function () {
})
test("should insert into dom when modal:show event is called", function () {
+ stop()
$.support.transition = false
var div = $("<div id='modal-test'></div>")
- div.modal().trigger("modal:show")
- ok($('#modal-test').length, 'modal insterted into dom')
- div.remove()
+ div
+ .modal()
+ .trigger("modal:show")
+ .bind("modal:shown", function () {
+ ok($('#modal-test').length, 'modal insterted into dom')
+ start()
+ div.remove()
+ })
})
- test("should remove from dom when close is called", function () {
+ test("should remove from dom when modal:hide is called", function () {
+ stop()
$.support.transition = false
var div = $("<div id='modal-test'></div>")
- div.modal().trigger("modal:show")
- ok($('#modal-test').length, 'modal insterted into dom')
- div.trigger("modal:hide")
- ok(!$('#modal-test').length, 'modal removed from dom')
- div.remove()
+ div
+ .modal()
+ .trigger("modal:show")
+ .bind("modal:shown", function () {
+ ok($('#modal-test').length, 'modal insterted into dom')
+ div.trigger("modal:hide")
+ })
+ .bind("modal:hidden", function() {
+ ok(!$('#modal-test').length, 'modal removed from dom')
+ start()
+ div.remove()
+ })
})
test("should toggle when toggle is called", function () {
+ stop()
$.support.transition = false
var div = $("<div id='modal-test'></div>")
- div.modal().trigger("modal:toggle")
- ok($('#modal-test').length, 'modal insterted into dom')
- div.trigger("modal:toggle")
- ok(!$('#modal-test').length, 'modal removed from dom')
- div.remove()
+ div
+ .modal()
+ .trigger("modal:toggle")
+ .bind("modal:shown", function () {
+ ok($('#modal-test').length, 'modal insterted into dom')
+ div.trigger("modal:toggle")
+ })
+ .bind("modal:hidden", function() {
+ ok(!$('#modal-test').length, 'modal removed from dom')
+ start()
+ div.remove()
+ })
})
test("should remove from dom when click .close", function () {
+ stop()
$.support.transition = false
var div = $("<div id='modal-test'><span class='close'></span></div>")
- div.modal().trigger("modal:toggle")
- ok($('#modal-test').length, 'modal insterted into dom')
- div.find('.close').click()
- ok(!$('#modal-test').length, 'modal removed from dom')
- div.remove()
+ div
+ .modal()
+ .trigger("modal:toggle")
+ .bind("modal:shown", function () {
+ ok($('#modal-test').length, 'modal insterted into dom')
+ div.find('.close').click()
+ })
+ .bind("modal:hidden", function() {
+ ok(!$('#modal-test').length, 'modal removed from dom')
+ start()
+ div.remove()
+ })
})
}) \ No newline at end of file
diff --git a/js/tests/unit/bootstrap-scrollspy.js b/js/tests/unit/bootstrap-scrollspy.js
new file mode 100644
index 000000000..b9b309062
--- /dev/null
+++ b/js/tests/unit/bootstrap-scrollspy.js
@@ -0,0 +1,31 @@
+$(function () {
+
+ module("bootstrap-scrollspy")
+
+ test("should be defined on jquery object", function () {
+ ok($(document.body).scrollspy, 'scrollspy method is defined')
+ })
+
+ test("should return element", function () {
+ ok($(document.body).scrollspy()[0] == document.body, 'document.body returned')
+ })
+
+ test("should switch active class on scroll", function () {
+ var sectionHTML = '<div id="masthead"></div>'
+ , $section = $(sectionHTML).append('#qunit-runoff')
+ , topbarHTML ='<div class="topbar">'
+ + '<div class="topbar-inner">'
+ + '<div class="container">'
+ + '<h3><a href="#">Bootstrap</a></h3>'
+ + '<ul class="nav">'
+ + '<li><a href="#masthead">Overview</a></li>'
+ + '</ul>'
+ + '</div>'
+ + '</div>'
+ + '</div>'
+ , $topbar = $(topbarHTML).topbar()
+
+ ok(topbar.find('.active', true)
+ })
+
+}) \ No newline at end of file