3 module("bootstrap-buttons")
5 test("should provide no conflict", function () {
6 var button = $.fn.button.noConflict()
7 ok(!$.fn.button, 'button was set back to undefined (org value)')
11 test("should be defined on jquery object", function () {
12 ok($(document.body).button, 'button method is defined')
15 test("should return element", function () {
16 ok($(document.body).button()[0] == document.body, 'document.body returned')
19 test("should return set state to loading", function () {
20 var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
21 equals(btn.html(), 'mdo', 'btn text equals mdo')
23 equals(btn.html(), 'fat', 'btn text equals fat')
25 setTimeout(function () {
26 ok(btn.attr('disabled'), 'btn is disabled')
27 ok(btn.hasClass('disabled'), 'btn has disabled class')
32 test("should return reset state", function () {
33 var btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
34 equals(btn.html(), 'mdo', 'btn text equals mdo')
36 equals(btn.html(), 'fat', 'btn text equals fat')
38 setTimeout(function () {
39 ok(btn.attr('disabled'), 'btn is disabled')
40 ok(btn.hasClass('disabled'), 'btn has disabled class')
45 equals(btn.html(), 'mdo', 'btn text equals mdo')
46 setTimeout(function () {
47 ok(!btn.attr('disabled'), 'btn is not disabled')
48 ok(!btn.hasClass('disabled'), 'btn does not have disabled class')
53 test("should toggle active", function () {
54 var btn = $('<button class="btn">mdo</button>')
55 ok(!btn.hasClass('active'), 'btn does not have active class')
57 ok(btn.hasClass('active'), 'btn has class active')
60 test("should toggle active when btn children are clicked", function () {
61 var btn = $('<button class="btn" data-toggle="button">mdo</button>')
62 , inner = $('<i></i>')
65 .appendTo($('#qunit-fixture'))
66 ok(!btn.hasClass('active'), 'btn does not have active class')
68 ok(btn.hasClass('active'), 'btn has class active')
71 test("should toggle active when btn children are clicked within btn-group", function () {
72 var btngroup = $('<div class="btn-group" data-toggle="buttons-checkbox"></div>')
73 , btn = $('<button class="btn">fat</button>')
74 , inner = $('<i></i>')
76 .append(btn.append(inner))
77 .appendTo($('#qunit-fixture'))
78 ok(!btn.hasClass('active'), 'btn does not have active class')
80 ok(btn.hasClass('active'), 'btn has class active')
83 test("should check for closest matching toggle", function () {
84 var group = $("<div data-toggle='buttons-radio'></div>")
85 , btn1 = $("<button class='btn active'></button>")
86 , btn2 = $("<button class='btn'></button>")
87 , wrap = $("<div></div>")
89 wrap.append(btn1, btn2)
93 .appendTo($('#qunit-fixture'))
95 ok(btn1.hasClass('active'), 'btn1 has active class')
96 ok(!btn2.hasClass('active'), 'btn2 does not have active class')
98 ok(!btn1.hasClass('active'), 'btn1 does not have active class')
99 ok(btn2.hasClass('active'), 'btn2 has active class')