diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js index 7a0660ea20..6c48ed44b4 100644 --- a/js/tests/unit/modal.js +++ b/js/tests/unit/modal.js @@ -4,8 +4,7 @@ $(function () { module('modal plugin') test('should be defined on jquery object', function () { - var div = $('
') - ok(div.modal, 'modal method is defined') + ok($(document.body).modal, 'modal method is defined') }) module('modal', { @@ -20,13 +19,14 @@ $(function () { }) test('should provide no conflict', function () { - ok(!$.fn.modal, 'modal was set back to undefined (orig value)') + strictEqual($.fn.modal, undefined, 'modal was set back to undefined (orig value)') }) - test('should return element', function () { - var div = $('') - ok(div.bootstrapModal() == div, 'document.body returned') - $('#modal-test').remove() + test('should return jquery collection containing the element', function () { + var $el = $('') + var $modal = $el.bootstrapModal() + ok($modal instanceof $, 'returns jquery collection') + strictEqual($modal[0], $el[0], 'collection contains element') }) test('should expose defaults var for settings', function () { @@ -35,11 +35,10 @@ $(function () { test('should insert into dom when show method is called', function () { stop() - $.support.transition = false - $('') + + $('') .on('shown.bs.modal', function () { - ok($('#modal-test').length, 'modal inserted into dom') - $(this).remove() + notEqual($('#modal-test').length, 0, 'modal inserted into dom') start() }) .bootstrapModal('show') @@ -47,46 +46,41 @@ $(function () { test('should fire show event', function () { stop() - $.support.transition = false - $('') + + $('') .on('show.bs.modal', function () { - ok(true, 'show was called') - }) - .on('shown.bs.modal', function () { - $(this).remove() + ok(true, 'show event fired') start() }) .bootstrapModal('show') }) - test('should not fire shown when default prevented', function () { + test('should not fire shown when show was prevented', function () { stop() - $.support.transition = false - $('') + + $('') .on('show.bs.modal', function (e) { e.preventDefault() - ok(true, 'show was called') + ok(true, 'show event fired') start() }) .on('shown.bs.modal', function () { - ok(false, 'shown was called') + ok(false, 'shown event fired') }) .bootstrapModal('show') }) test('should hide modal when hide is called', function () { stop() - $.support.transition = false - $('') + $('') .on('shown.bs.modal', function () { ok($('#modal-test').is(':visible'), 'modal visible') - ok($('#modal-test').length, 'modal inserted into dom') + notEqual($('#modal-test').length, 0, 'modal inserted into dom') $(this).bootstrapModal('hide') }) .on('hidden.bs.modal', function () { ok(!$('#modal-test').is(':visible'), 'modal hidden') - $('#modal-test').remove() start() }) .bootstrapModal('show') @@ -94,17 +88,15 @@ $(function () { test('should toggle when toggle is called', function () { stop() - $.support.transition = false - var div = $('') - div + + $('') .on('shown.bs.modal', function () { ok($('#modal-test').is(':visible'), 'modal visible') - ok($('#modal-test').length, 'modal inserted into dom') - div.bootstrapModal('toggle') + notEqual($('#modal-test').length, 0, 'modal inserted into dom') + $(this).bootstrapModal('toggle') }) .on('hidden.bs.modal', function () { ok(!$('#modal-test').is(':visible'), 'modal hidden') - div.remove() start() }) .bootstrapModal('toggle') @@ -112,17 +104,15 @@ $(function () { test('should remove from dom when click [data-dismiss="modal"]', function () { stop() - $.support.transition = false - var div = $('