Mercurial > wikked
comparison static/bootstrap/js/tests/unit/bootstrap-modal.js @ 88:a5a3d454eac9
Updated Bootstrap.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 05 Apr 2013 08:08:12 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
87:c0cf67362fb1 | 88:a5a3d454eac9 |
---|---|
1 $(function () { | |
2 | |
3 module("bootstrap-modal") | |
4 | |
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)') | |
8 $.fn.modal = modal | |
9 }) | |
10 | |
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') | |
14 }) | |
15 | |
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() | |
20 }) | |
21 | |
22 test("should expose defaults var for settings", function () { | |
23 ok($.fn.modal.defaults, 'default object exposed') | |
24 }) | |
25 | |
26 test("should insert into dom when show method is called", function () { | |
27 stop() | |
28 $.support.transition = false | |
29 $("<div id='modal-test'></div>") | |
30 .bind("shown", function () { | |
31 ok($('#modal-test').length, 'modal insterted into dom') | |
32 $(this).remove() | |
33 start() | |
34 }) | |
35 .modal("show") | |
36 }) | |
37 | |
38 test("should fire show event", function () { | |
39 stop() | |
40 $.support.transition = false | |
41 $("<div id='modal-test'></div>") | |
42 .bind("show", function () { | |
43 ok(true, "show was called") | |
44 }) | |
45 .bind("shown", function () { | |
46 $(this).remove() | |
47 start() | |
48 }) | |
49 .modal("show") | |
50 }) | |
51 | |
52 test("should not fire shown when default prevented", function () { | |
53 stop() | |
54 $.support.transition = false | |
55 $("<div id='modal-test'></div>") | |
56 .bind("show", function (e) { | |
57 e.preventDefault() | |
58 ok(true, "show was called") | |
59 start() | |
60 }) | |
61 .bind("shown", function () { | |
62 ok(false, "shown was called") | |
63 }) | |
64 .modal("show") | |
65 }) | |
66 | |
67 test("should hide modal when hide is called", function () { | |
68 stop() | |
69 $.support.transition = false | |
70 | |
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') | |
75 $(this).modal("hide") | |
76 }) | |
77 .bind("hidden", function() { | |
78 ok(!$('#modal-test').is(":visible"), 'modal hidden') | |
79 $('#modal-test').remove() | |
80 start() | |
81 }) | |
82 .modal("show") | |
83 }) | |
84 | |
85 test("should toggle when toggle is called", function () { | |
86 stop() | |
87 $.support.transition = false | |
88 var div = $("<div id='modal-test'></div>") | |
89 div | |
90 .bind("shown", function () { | |
91 ok($('#modal-test').is(":visible"), 'modal visible') | |
92 ok($('#modal-test').length, 'modal insterted into dom') | |
93 div.modal("toggle") | |
94 }) | |
95 .bind("hidden", function() { | |
96 ok(!$('#modal-test').is(":visible"), 'modal hidden') | |
97 div.remove() | |
98 start() | |
99 }) | |
100 .modal("toggle") | |
101 }) | |
102 | |
103 test("should remove from dom when click [data-dismiss=modal]", function () { | |
104 stop() | |
105 $.support.transition = false | |
106 var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>") | |
107 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() | |
112 }) | |
113 .bind("hidden", function() { | |
114 ok(!$('#modal-test').is(":visible"), 'modal hidden') | |
115 div.remove() | |
116 start() | |
117 }) | |
118 .modal("toggle") | |
119 }) | |
120 | |
121 test("should allow modal close with 'backdrop:false'", function () { | |
122 stop() | |
123 $.support.transition = false | |
124 var div = $("<div>", { id: 'modal-test', "data-backdrop": false }) | |
125 div | |
126 .bind("shown", function () { | |
127 ok($('#modal-test').is(":visible"), 'modal visible') | |
128 div.modal("hide") | |
129 }) | |
130 .bind("hidden", function() { | |
131 ok(!$('#modal-test').is(":visible"), 'modal hidden') | |
132 div.remove() | |
133 start() | |
134 }) | |
135 .modal("show") | |
136 }) | |
137 }) |