aboutsummaryrefslogtreecommitdiff
path: root/js/tests/unit
diff options
context:
space:
mode:
authorJacob Thornton <[email protected]>2011-10-29 18:49:35 -0700
committerJacob Thornton <[email protected]>2011-10-29 18:49:35 -0700
commitea50e8aeeed6616a61a7e44d28fe60ced327be0c (patch)
treec4b4e7a6c81da4145d638ede025ba14eac2f47ff /js/tests/unit
parente8b66a9626055957a378464e2b9204f156b34c17 (diff)
downloadbootstrap-ea50e8aeeed6616a61a7e44d28fe60ced327be0c.tar.xz
bootstrap-ea50e8aeeed6616a61a7e44d28fe60ced327be0c.zip
add active class to css for buttons, write new spec for button, "use strict"
Diffstat (limited to 'js/tests/unit')
-rw-r--r--js/tests/unit/bootstrap-buttons.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/tests/unit/bootstrap-buttons.js b/js/tests/unit/bootstrap-buttons.js
new file mode 100644
index 000000000..9784f5222
--- /dev/null
+++ b/js/tests/unit/bootstrap-buttons.js
@@ -0,0 +1,42 @@
+$(function () {
+
+ module("bootstrap-buttons")
+
+ test("should be defined on jquery object", function () {
+ ok($(document.body).button, 'tabs method is defined')
+ })
+
+ test("should return element", function () {
+ ok($(document.body).button()[0] == document.body, 'document.body returned')
+ })
+
+ test("should return set state to loading", function () {
+ var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
+ equals(btn.html(), 'mdo', 'btn text equals mdo')
+ btn.button('loading')
+ equals(btn.html(), 'fat', 'btn text equals fat')
+ ok(btn.attr('disabled'), 'btn is disabled')
+ ok(btn.hasClass('disabled'), 'btn has disabled class')
+ })
+
+ test("should return reset state", function () {
+ var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
+ equals(btn.html(), 'mdo', 'btn text equals mdo')
+ btn.button('loading')
+ equals(btn.html(), 'fat', 'btn text equals fat')
+ ok(btn.attr('disabled'), 'btn is disabled')
+ ok(btn.hasClass('disabled'), 'btn is disabled')
+ btn.button('reset')
+ equals(btn.html(), 'mdo', 'btn text equals mdo')
+ ok(!btn.attr('disabled'), 'btn is not disabled')
+ ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
+ })
+
+ test("should toggle active", function () {
+ var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
+ ok(!btn.hasClass('active'), 'btn does not have active class')
+ btn.button('toggle')
+ ok(btn.hasClass('active'), 'btn has class active')
+ })
+
+}) \ No newline at end of file