An error occurred while loading the file. Please try again.
-
Alessandro Chitolina authored6cfc78f2
$(function () {
'use strict';
module('modal plugin')
test('should be defined on jquery object', function () {
ok($(document.body).modal, 'modal method is defined')
})
module('modal', {
setup: function () {
// Run all tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode
$.fn.bootstrapModal = $.fn.modal.noConflict()
},
teardown: function () {
$.fn.modal = $.fn.bootstrapModal
delete $.fn.bootstrapModal
}
})
test('should provide no conflict', function () {
strictEqual($.fn.modal, undefined, 'modal was set back to undefined (orig value)')
})
test('should return jquery collection containing the element', function () {
var $el = $('<div id="modal-test"/>')
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 () {
ok($.fn.bootstrapModal.Constructor.DEFAULTS, 'default object exposed')
})
test('should insert into dom when show method is called', function (assert) {
var done = assert.async()
$('<div id="modal-test"/>')
.on('shown.bs.modal', function () {
notEqual($('#modal-test').length, 0, 'modal inserted into dom')
done()
})
.bootstrapModal('show')
})
test('should fire show event', function (assert) {
var done = assert.async()
$('<div id="modal-test"/>')
.on('show.bs.modal', function () {
ok(true, 'show event fired')
done()
})
.bootstrapModal('show')
})
test('should not fire shown when show was prevented', function (assert) {
var done = assert.async()
$('<div id="modal-test"/>')
.on('show.bs.modal', function (e) {
e.preventDefault()
ok(true, 'show event fired')
done()
})
.on('shown.bs.modal', function () {
ok(false, 'shown event fired')
})
.bootstrapModal('show')