2011-09-10 07:47:49 +02:00
|
|
|
$(function () {
|
|
|
|
|
2013-05-16 20:06:30 +02:00
|
|
|
module("modal")
|
2011-09-10 07:47:49 +02:00
|
|
|
|
2012-12-07 23:06:01 +01:00
|
|
|
test("should provide no conflict", function () {
|
|
|
|
var modal = $.fn.modal.noConflict()
|
|
|
|
ok(!$.fn.modal, 'modal was set back to undefined (org value)')
|
|
|
|
$.fn.modal = modal
|
|
|
|
})
|
|
|
|
|
2011-09-10 07:47:49 +02:00
|
|
|
test("should be defined on jquery object", function () {
|
2011-09-10 21:49:21 +02:00
|
|
|
var div = $("<div id='modal-test'></div>")
|
|
|
|
ok(div.modal, 'modal method is defined')
|
2011-09-10 07:47:49 +02:00
|
|
|
})
|
|
|
|
|
2011-09-10 21:49:21 +02:00
|
|
|
test("should return element", function () {
|
|
|
|
var div = $("<div id='modal-test'></div>")
|
|
|
|
ok(div.modal() == div, 'document.body returned')
|
2011-12-21 03:02:47 +01:00
|
|
|
$('#modal-test').remove()
|
2011-09-10 07:47:49 +02:00
|
|
|
})
|
|
|
|
|
2011-09-10 21:49:21 +02:00
|
|
|
test("should expose defaults var for settings", function () {
|
2013-05-17 02:44:50 +02:00
|
|
|
ok($.fn.modal.Constructor.DEFAULTS, 'default object exposed')
|
2011-09-10 07:47:49 +02:00
|
|
|
})
|
|
|
|
|
2011-09-12 07:58:51 +02:00
|
|
|
test("should insert into dom when show method is called", function () {
|
2011-09-11 07:14:57 +02:00
|
|
|
stop()
|
2011-09-10 21:49:21 +02:00
|
|
|
$.support.transition = false
|
2011-12-21 03:02:47 +01:00
|
|
|
$("<div id='modal-test'></div>")
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:shown", function () {
|
2011-09-11 07:14:57 +02:00
|
|
|
ok($('#modal-test').length, 'modal insterted into dom')
|
2011-12-21 03:02:47 +01:00
|
|
|
$(this).remove()
|
2011-09-11 07:14:57 +02:00
|
|
|
start()
|
|
|
|
})
|
2011-12-21 03:02:47 +01:00
|
|
|
.modal("show")
|
2011-09-10 07:47:49 +02:00
|
|
|
})
|
|
|
|
|
2012-03-25 01:50:21 +01:00
|
|
|
test("should fire show event", function () {
|
|
|
|
stop()
|
|
|
|
$.support.transition = false
|
|
|
|
$("<div id='modal-test'></div>")
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:show", function () {
|
2012-03-25 01:50:21 +01:00
|
|
|
ok(true, "show was called")
|
|
|
|
})
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:shown", function () {
|
2012-03-25 01:50:21 +01:00
|
|
|
$(this).remove()
|
|
|
|
start()
|
|
|
|
})
|
|
|
|
.modal("show")
|
|
|
|
})
|
|
|
|
|
|
|
|
test("should not fire shown when default prevented", function () {
|
|
|
|
stop()
|
|
|
|
$.support.transition = false
|
|
|
|
$("<div id='modal-test'></div>")
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:show", function (e) {
|
2012-03-25 01:50:21 +01:00
|
|
|
e.preventDefault()
|
|
|
|
ok(true, "show was called")
|
|
|
|
start()
|
|
|
|
})
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:shown", function () {
|
2012-03-25 01:50:21 +01:00
|
|
|
ok(false, "shown was called")
|
|
|
|
})
|
|
|
|
.modal("show")
|
|
|
|
})
|
|
|
|
|
2011-09-12 07:58:51 +02:00
|
|
|
test("should hide modal when hide is called", function () {
|
2011-09-11 07:14:57 +02:00
|
|
|
stop()
|
2011-09-10 21:49:21 +02:00
|
|
|
$.support.transition = false
|
2011-12-21 03:02:47 +01:00
|
|
|
|
|
|
|
$("<div id='modal-test'></div>")
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:shown", function () {
|
2011-09-12 07:58:51 +02:00
|
|
|
ok($('#modal-test').is(":visible"), 'modal visible')
|
2011-09-11 07:14:57 +02:00
|
|
|
ok($('#modal-test').length, 'modal insterted into dom')
|
2011-12-21 03:02:47 +01:00
|
|
|
$(this).modal("hide")
|
2011-09-11 07:14:57 +02:00
|
|
|
})
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:hidden", function() {
|
2011-09-12 07:58:51 +02:00
|
|
|
ok(!$('#modal-test').is(":visible"), 'modal hidden')
|
2011-12-21 03:02:47 +01:00
|
|
|
$('#modal-test').remove()
|
2011-09-11 07:14:57 +02:00
|
|
|
start()
|
|
|
|
})
|
2011-09-12 07:58:51 +02:00
|
|
|
.modal("show")
|
2011-09-10 07:47:49 +02:00
|
|
|
})
|
|
|
|
|
2011-09-10 21:49:21 +02:00
|
|
|
test("should toggle when toggle is called", function () {
|
2011-09-11 07:14:57 +02:00
|
|
|
stop()
|
2011-09-10 07:47:49 +02:00
|
|
|
$.support.transition = false
|
2011-09-10 21:49:21 +02:00
|
|
|
var div = $("<div id='modal-test'></div>")
|
2011-09-11 07:14:57 +02:00
|
|
|
div
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:shown", function () {
|
2011-09-12 07:58:51 +02:00
|
|
|
ok($('#modal-test').is(":visible"), 'modal visible')
|
2011-09-11 07:14:57 +02:00
|
|
|
ok($('#modal-test').length, 'modal insterted into dom')
|
2011-09-12 07:58:51 +02:00
|
|
|
div.modal("toggle")
|
2011-09-11 07:14:57 +02:00
|
|
|
})
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:hidden", function() {
|
2011-09-12 07:58:51 +02:00
|
|
|
ok(!$('#modal-test').is(":visible"), 'modal hidden')
|
2011-09-11 07:14:57 +02:00
|
|
|
div.remove()
|
2011-12-21 03:02:47 +01:00
|
|
|
start()
|
2011-09-11 07:14:57 +02:00
|
|
|
})
|
2011-09-12 07:58:51 +02:00
|
|
|
.modal("toggle")
|
2011-09-10 07:47:49 +02:00
|
|
|
})
|
|
|
|
|
2011-12-21 03:02:47 +01:00
|
|
|
test("should remove from dom when click [data-dismiss=modal]", function () {
|
2011-09-11 07:14:57 +02:00
|
|
|
stop()
|
2011-09-10 21:49:21 +02:00
|
|
|
$.support.transition = false
|
2011-12-21 03:02:47 +01:00
|
|
|
var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>")
|
2011-09-11 07:14:57 +02:00
|
|
|
div
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:shown", function () {
|
2011-09-12 07:58:51 +02:00
|
|
|
ok($('#modal-test').is(":visible"), 'modal visible')
|
2011-09-11 07:14:57 +02:00
|
|
|
ok($('#modal-test').length, 'modal insterted into dom')
|
|
|
|
div.find('.close').click()
|
|
|
|
})
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:hidden", function() {
|
2011-09-12 07:58:51 +02:00
|
|
|
ok(!$('#modal-test').is(":visible"), 'modal hidden')
|
2011-09-11 07:14:57 +02:00
|
|
|
div.remove()
|
2011-12-21 03:02:47 +01:00
|
|
|
start()
|
2011-09-11 07:14:57 +02:00
|
|
|
})
|
2011-09-12 07:58:51 +02:00
|
|
|
.modal("toggle")
|
2011-09-10 21:49:21 +02:00
|
|
|
})
|
2013-03-01 06:15:33 +01:00
|
|
|
|
|
|
|
test("should allow modal close with 'backdrop:false'", function () {
|
|
|
|
stop()
|
|
|
|
$.support.transition = false
|
|
|
|
var div = $("<div>", { id: 'modal-test', "data-backdrop": false })
|
|
|
|
div
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:shown", function () {
|
2013-03-01 06:15:33 +01:00
|
|
|
ok($('#modal-test').is(":visible"), 'modal visible')
|
|
|
|
div.modal("hide")
|
|
|
|
})
|
2013-05-17 02:44:50 +02:00
|
|
|
.bind("bs:modal:hidden", function() {
|
2013-03-01 06:15:33 +01:00
|
|
|
ok(!$('#modal-test').is(":visible"), 'modal hidden')
|
|
|
|
div.remove()
|
|
|
|
start()
|
|
|
|
})
|
|
|
|
.modal("show")
|
|
|
|
})
|
2013-04-23 09:34:27 +02:00
|
|
|
})
|