summaryrefslogtreecommitdiff
path: root/tbc/static/js/tests/unit/bootstrap-modal.js
diff options
context:
space:
mode:
authorhardythe12013-10-22 17:31:15 +0530
committerhardythe12013-10-22 17:31:15 +0530
commitc7b48513fb2cb0cdd0e4ec0050b8dbcbddc698f5 (patch)
tree52b3a71ce8b42ca74a9bd92fff4560fcb3cf7895 /tbc/static/js/tests/unit/bootstrap-modal.js
parent266347a58de32b21c3fa1ae3b9a4b466d4584372 (diff)
downloadPython-TBC-Interface-c7b48513fb2cb0cdd0e4ec0050b8dbcbddc698f5.tar.gz
Python-TBC-Interface-c7b48513fb2cb0cdd0e4ec0050b8dbcbddc698f5.tar.bz2
Python-TBC-Interface-c7b48513fb2cb0cdd0e4ec0050b8dbcbddc698f5.zip
Adding the project initial commit
Diffstat (limited to 'tbc/static/js/tests/unit/bootstrap-modal.js')
-rwxr-xr-xtbc/static/js/tests/unit/bootstrap-modal.js137
1 files changed, 137 insertions, 0 deletions
diff --git a/tbc/static/js/tests/unit/bootstrap-modal.js b/tbc/static/js/tests/unit/bootstrap-modal.js
new file mode 100755
index 0000000..b0096f8
--- /dev/null
+++ b/tbc/static/js/tests/unit/bootstrap-modal.js
@@ -0,0 +1,137 @@
+$(function () {
+
+ module("bootstrap-modal")
+
+ 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
+ })
+
+ test("should be defined on jquery object", function () {
+ var div = $("<div id='modal-test'></div>")
+ ok(div.modal, 'modal method is defined')
+ })
+
+ test("should return element", function () {
+ var div = $("<div id='modal-test'></div>")
+ ok(div.modal() == div, 'document.body returned')
+ $('#modal-test').remove()
+ })
+
+ test("should expose defaults var for settings", function () {
+ ok($.fn.modal.defaults, 'default object exposed')
+ })
+
+ test("should insert into dom when show method is called", function () {
+ stop()
+ $.support.transition = false
+ $("<div id='modal-test'></div>")
+ .bind("shown", function () {
+ ok($('#modal-test').length, 'modal insterted into dom')
+ $(this).remove()
+ start()
+ })
+ .modal("show")
+ })
+
+ test("should fire show event", function () {
+ stop()
+ $.support.transition = false
+ $("<div id='modal-test'></div>")
+ .bind("show", function () {
+ ok(true, "show was called")
+ })
+ .bind("shown", function () {
+ $(this).remove()
+ start()
+ })
+ .modal("show")
+ })
+
+ test("should not fire shown when default prevented", function () {
+ stop()
+ $.support.transition = false
+ $("<div id='modal-test'></div>")
+ .bind("show", function (e) {
+ e.preventDefault()
+ ok(true, "show was called")
+ start()
+ })
+ .bind("shown", function () {
+ ok(false, "shown was called")
+ })
+ .modal("show")
+ })
+
+ test("should hide modal when hide is called", function () {
+ stop()
+ $.support.transition = false
+
+ $("<div id='modal-test'></div>")
+ .bind("shown", function () {
+ ok($('#modal-test').is(":visible"), 'modal visible')
+ ok($('#modal-test').length, 'modal insterted into dom')
+ $(this).modal("hide")
+ })
+ .bind("hidden", function() {
+ ok(!$('#modal-test').is(":visible"), 'modal hidden')
+ $('#modal-test').remove()
+ start()
+ })
+ .modal("show")
+ })
+
+ test("should toggle when toggle is called", function () {
+ stop()
+ $.support.transition = false
+ var div = $("<div id='modal-test'></div>")
+ div
+ .bind("shown", function () {
+ ok($('#modal-test').is(":visible"), 'modal visible')
+ ok($('#modal-test').length, 'modal insterted into dom')
+ div.modal("toggle")
+ })
+ .bind("hidden", function() {
+ ok(!$('#modal-test').is(":visible"), 'modal hidden')
+ div.remove()
+ start()
+ })
+ .modal("toggle")
+ })
+
+ test("should remove from dom when click [data-dismiss=modal]", function () {
+ stop()
+ $.support.transition = false
+ var div = $("<div id='modal-test'><span class='close' data-dismiss='modal'></span></div>")
+ div
+ .bind("shown", function () {
+ ok($('#modal-test').is(":visible"), 'modal visible')
+ ok($('#modal-test').length, 'modal insterted into dom')
+ div.find('.close').click()
+ })
+ .bind("hidden", function() {
+ ok(!$('#modal-test').is(":visible"), 'modal hidden')
+ div.remove()
+ start()
+ })
+ .modal("toggle")
+ })
+
+ test("should allow modal close with 'backdrop:false'", function () {
+ stop()
+ $.support.transition = false
+ var div = $("<div>", { id: 'modal-test', "data-backdrop": false })
+ div
+ .bind("shown", function () {
+ ok($('#modal-test').is(":visible"), 'modal visible')
+ div.modal("hide")
+ })
+ .bind("hidden", function() {
+ ok(!$('#modal-test').is(":visible"), 'modal hidden')
+ div.remove()
+ start()
+ })
+ .modal("show")
+ })
+}) \ No newline at end of file