From ea50e8aeeed6616a61a7e44d28fe60ced327be0c Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 29 Oct 2011 18:49:35 -0700 Subject: add active class to css for buttons, write new spec for button, "use strict" --- js/tests/index.html | 4 +++- js/tests/unit/bootstrap-buttons.js | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 js/tests/unit/bootstrap-buttons.js (limited to 'js/tests') diff --git a/js/tests/index.html b/js/tests/index.html index 2ca94102a..355c3f0af 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -4,7 +4,7 @@ Bootstrap Plugin Test Suite - + @@ -17,6 +17,7 @@ + @@ -25,6 +26,7 @@ +
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 = $('') + 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 = $('') + 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 = $('') + 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 -- cgit v1.2.3