3 module("bootstrap-modal")
5 test("should provide no conflict", function () {
6 var modal = $.fn.modal.noConflict()
7 ok(!$.fn.modal, 'modal was set back to undefined (org value)')
11 test("should be defined on jquery object", function () {
12 var div = $("<div id='modal-test'></div>")
13 ok(div.modal, 'modal method is defined')
16 test("should return element", function () {
17 var div = $("<div id='modal-test'></div>")
18 ok(div.modal() == div, 'document.body returned')
19 $('#modal-test').remove()
22 test("should expose defaults var for settings", function () {
23 ok($.fn.modal.defaults, 'default object exposed')
26 test("should insert into dom when show method is called", function () {
28 $.support.transition = false
29 $("<div id='modal-test'></div>")
30 .bind("shown", function () {
31 ok($('#modal-test').length, 'modal insterted into dom')
38 test("should fire show event", function () {
40 $.support.transition = false
41 $("<div id='modal-test'></div>")
42 .bind("show", function () {
43 ok(true, "show was called")
45 .bind("shown", function () {
52 test("should not fire shown when default prevented", function () {
54 $.support.transition = false
55 $("<div id='modal-test'></div>")
56 .bind("show", function (e) {
58 ok(true, "show was called")
61 .bind("shown", function () {
62 ok(false, "shown was called")
67 test("should hide modal when hide is called", function () {
69 $.support.transition = false
71 $("<div id='modal-test'></div>")
72 .bind("shown", function () {
73 ok($('#modal-test').is(":visible"), 'modal visible')
74 ok($('#modal-test').length, 'modal insterted into dom')
77 .bind("hidden", function() {
78 ok(!$('#modal-test').is(":visible"), 'modal hidden')
79 $('#modal-test').remove()
85 test("should toggle when toggle is called", function () {
87 $.support.transition = false
88 var div = $("<div id='modal-test'></div>")
90 .bind("shown", function () {
91 ok($('#modal-test').is(":visible"), 'modal visible')
92 ok($('#modal-test').length, 'modal insterted into dom')
95 .bind("hidden", function() {
96 ok(!$('#modal-test').is(":visible"), 'modal hidden')
103 test("should remove from dom when click [data-dismiss=modal]", function () {
105 $.support.transition = false
106 var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>")
108 .bind("shown", function () {
109 ok($('#modal-test').is(":visible"), 'modal visible')
110 ok($('#modal-test').length, 'modal insterted into dom')
111 div.find('.close').click()
113 .bind("hidden", function() {
114 ok(!$('#modal-test').is(":visible"), 'modal hidden')
121 test("should allow modal close with 'backdrop:false'", function () {
123 $.support.transition = false
124 var div = $("<div>", { id: 'modal-test', "data-backdrop": false })
126 .bind("shown", function () {
127 ok($('#modal-test').is(":visible"), 'modal visible')
130 .bind("hidden", function() {
131 ok(!$('#modal-test').is(":visible"), 'modal hidden')