diff options
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/index.html | 4 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-buttons.js | 42 |
2 files changed, 45 insertions, 1 deletions
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 @@ <title>Bootstrap Plugin Test Suite</title> <!-- jquery --> - <script src="http://code.jquery.com/jquery-1.5.2.min.js"></script> + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <!-- qunit --> <link rel="stylesheet" href="vendor/qunit.css" type="text/css" media="screen" /> @@ -17,6 +17,7 @@ <script src="../../js/bootstrap-tabs.js"></script> <script src="../../js/bootstrap-twipsy.js"></script> <script src="../../js/bootstrap-popover.js"></script> + <script src="../../js/bootstrap-buttons.js"></script> <!-- unit tests --> <script src="unit/bootstrap-alerts.js"></script> @@ -25,6 +26,7 @@ <script src="unit/bootstrap-popover.js"></script> <script src="unit/bootstrap-tabs.js"></script> <script src="unit/bootstrap-twipsy.js"></script> + <script src="unit/bootstrap-buttons.js"></script> <body> <div> 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 |
