info@54: $(function () { info@54: info@54: module("collapse") info@54: info@54: test("should provide no conflict", function () { info@54: var collapse = $.fn.collapse.noConflict() info@54: ok(!$.fn.collapse, 'collapse was set back to undefined (org value)') info@54: $.fn.collapse = collapse info@54: }) info@54: info@54: test("should be defined on jquery object", function () { info@54: ok($(document.body).collapse, 'collapse method is defined') info@54: }) info@54: info@54: test("should return element", function () { info@54: ok($(document.body).collapse()[0] == document.body, 'document.body returned') info@54: }) info@54: info@54: test("should show a collapsed element", function () { info@54: var el = $('
').collapse('show') info@54: ok(el.hasClass('in'), 'has class in') info@54: ok(/height/.test(el.attr('style')), 'has height set') info@54: }) info@54: info@54: test("should hide a collapsed element", function () { info@54: var el = $('').collapse('hide') info@54: ok(!el.hasClass('in'), 'does not have class in') info@54: ok(/height/.test(el.attr('style')), 'has height set') info@54: }) info@54: info@54: test("should not fire shown when show is prevented", function () { info@54: $.support.transition = false info@54: stop() info@54: $('') info@54: .on('show.bs.collapse', function (e) { info@54: e.preventDefault(); info@54: ok(true); info@54: start(); info@54: }) info@54: .on('shown.bs.collapse', function () { info@54: ok(false); info@54: }) info@54: .collapse('show') info@54: }) info@54: info@54: test("should reset style to auto after finishing opening collapse", function () { info@54: $.support.transition = false info@54: stop() info@54: $('') info@54: .on('show.bs.collapse', function () { info@54: ok(this.style.height == '0px') info@54: }) info@54: .on('shown.bs.collapse', function () { info@54: ok(this.style.height == 'auto') info@54: start() info@54: }) info@54: .collapse('show') info@54: }) info@54: info@54: test("should add active class to target when collapse shown", function () { info@54: $.support.transition = false info@54: stop() info@54: info@54: var target = $('') info@54: .appendTo($('#qunit-fixture')) info@54: info@54: var collapsible = $('') info@54: .appendTo($('#qunit-fixture')) info@54: .on('show.bs.collapse', function () { info@54: ok(!target.hasClass('collapsed')) info@54: start() info@54: }) info@54: info@54: target.click() info@54: }) info@54: info@54: test("should remove active class to target when collapse hidden", function () { info@54: $.support.transition = false info@54: stop() info@54: info@54: var target = $('') info@54: .appendTo($('#qunit-fixture')) info@54: info@54: var collapsible = $('') info@54: .appendTo($('#qunit-fixture')) info@54: .on('hide.bs.collapse', function () { info@54: ok(target.hasClass('collapsed')) info@54: start() info@54: }) info@54: info@54: target.click() info@54: }) info@54: info@54: test("should remove active class from inactive accordion targets", function () { info@54: $.support.transition = false info@54: stop() info@54: info@54: var accordion = $('