diff --git a/js/tests/unit/collapse.js b/js/tests/unit/collapse.js index 4a0cf2b2e..5522d53c6 100644 --- a/js/tests/unit/collapse.js +++ b/js/tests/unit/collapse.js @@ -19,156 +19,153 @@ $(function () { }) test('should provide no conflict', function () { - ok(!$.fn.collapse, 'collapse was set back to undefined (org value)') + strictEqual($.fn.collapse, undefined, 'collapse was set back to undefined (org value)') }) - test('should return element', function () { - ok($(document.body).bootstrapCollapse()[0] == document.body, 'document.body returned') + test('should return jquery collection containing the element', function () { + var $el = $('
') + var $collapse = $el.bootstrapCollapse() + ok($collapse instanceof $, 'returns jquery collection') + strictEqual($collapse[0], $el[0], 'collection contains element') }) test('should show a collapsed element', function () { - var el = $('').bootstrapCollapse('show') - ok(el.hasClass('in'), 'has class in') - ok(!/height/.test(el.attr('style')), 'has height reset') + var $el = $('').bootstrapCollapse('show') + + ok($el.hasClass('in'), 'has class "in"') + ok(!/height/.test($el.attr('style')), 'has height reset') }) test('should hide a collapsed element', function () { - var el = $('').bootstrapCollapse('hide') - ok(!el.hasClass('in'), 'does not have class in') - ok(/height/.test(el.attr('style')), 'has height set') + var $el = $('').bootstrapCollapse('hide') + + ok(!$el.hasClass('in'), 'does not have class "in"') + ok(/height/.test($el.attr('style')), 'has height set') }) test('should not fire shown when show is prevented', function () { - $.support.transition = false stop() + $('') .on('show.bs.collapse', function (e) { e.preventDefault() - ok(true) + ok(true, 'show event fired') start() }) .on('shown.bs.collapse', function () { - ok(false) + ok(false, 'shown event fired') }) .bootstrapCollapse('show') }) test('should reset style to auto after finishing opening collapse', function () { - $.support.transition = false stop() + $('') .on('show.bs.collapse', function () { - ok(this.style.height == '0px') + equal(this.style.height, '0px', 'height is 0px') }) .on('shown.bs.collapse', function () { - ok(this.style.height === '') + strictEqual(this.style.height, '', 'height is auto') start() }) .bootstrapCollapse('show') }) - test('should add active class to target when collapse shown', function () { - $.support.transition = false + test('should remove "collapsed" class from target when collapse is shown', function () { stop() - var target = $('') - .appendTo($('#qunit-fixture')) + var $target = $('').appendTo('#qunit-fixture') - $('') - .appendTo($('#qunit-fixture')) + $('') + .appendTo('#qunit-fixture') .on('show.bs.collapse', function () { - ok(!target.hasClass('collapsed')) + ok(!$target.hasClass('collapsed')) start() }) - target.click() + $target.click() }) - test('should remove active class to target when collapse hidden', function () { - $.support.transition = false + test('should add "collapsed" class to target when collapse is hidden', function () { stop() - var target = $('') - .appendTo($('#qunit-fixture')) + var $target = $('').appendTo('#qunit-fixture') - $('') - .appendTo($('#qunit-fixture')) + $('') + .appendTo('#qunit-fixture') .on('hide.bs.collapse', function () { - ok(target.hasClass('collapsed')) + ok($target.hasClass('collapsed')) start() }) - target.click() + $target.click() }) - test('should remove active class from inactive accordion targets', function () { - $.support.transition = false + test('should remove "collapsed" class from active accordion target', function () { stop() - var accordion = $('