info@54: $(function () { info@54: info@54: module("button") info@54: info@54: test("should provide no conflict", function () { info@54: var button = $.fn.button.noConflict() info@54: ok(!$.fn.button, 'button was set back to undefined (org value)') info@54: $.fn.button = button info@54: }) info@54: info@54: test("should be defined on jquery object", function () { info@54: ok($(document.body).button, 'button method is defined') info@54: }) info@54: info@54: test("should return element", function () { info@54: ok($(document.body).button()[0] == document.body, 'document.body returned') info@54: }) info@54: info@54: test("should return set state to loading", function () { info@54: var btn = $('') info@54: equal(btn.html(), 'mdo', 'btn text equals mdo') info@54: btn.button('loading') info@54: equal(btn.html(), 'fat', 'btn text equals fat') info@54: stop() info@54: setTimeout(function () { info@54: ok(btn.attr('disabled'), 'btn is disabled') info@54: ok(btn.hasClass('disabled'), 'btn has disabled class') info@54: start() info@54: }, 0) info@54: }) info@54: info@54: test("should return reset state", function () { info@54: var btn = $('') info@54: equal(btn.html(), 'mdo', 'btn text equals mdo') info@54: btn.button('loading') info@54: equal(btn.html(), 'fat', 'btn text equals fat') info@54: stop() info@54: setTimeout(function () { info@54: ok(btn.attr('disabled'), 'btn is disabled') info@54: ok(btn.hasClass('disabled'), 'btn has disabled class') info@54: start() info@54: stop() info@54: btn.button('reset') info@54: equal(btn.html(), 'mdo', 'btn text equals mdo') info@54: setTimeout(function () { info@54: ok(!btn.attr('disabled'), 'btn is not disabled') info@54: ok(!btn.hasClass('disabled'), 'btn does not have disabled class') info@54: start() info@54: }, 0) info@54: }, 0) info@54: info@54: }) info@54: info@54: test("should toggle active", function () { info@54: var btn = $('') info@54: ok(!btn.hasClass('active'), 'btn does not have active class') info@54: btn.button('toggle') info@54: ok(btn.hasClass('active'), 'btn has class active') info@54: }) info@54: info@54: test("should toggle active when btn children are clicked", function () { info@54: var btn = $('') info@54: , inner = $('') info@54: btn info@54: .append(inner) info@54: .appendTo($('#qunit-fixture')) info@54: ok(!btn.hasClass('active'), 'btn does not have active class') info@54: inner.click() info@54: ok(btn.hasClass('active'), 'btn has class active') info@54: }) info@54: info@54: test("should toggle active when btn children are clicked within btn-group", function () { info@54: var btngroup = $('
') info@54: , btn = $('') info@54: , inner = $('') info@54: btngroup info@54: .append(btn.append(inner)) info@54: .appendTo($('#qunit-fixture')) info@54: ok(!btn.hasClass('active'), 'btn does not have active class') info@54: inner.click() info@54: ok(btn.hasClass('active'), 'btn has class active') info@54: }) info@54: info@54: test("should check for closest matching toggle", function () { info@54: var group = '