diff options
| author | Jacob Thornton <[email protected]> | 2012-01-31 13:18:34 -0800 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2012-01-31 13:18:34 -0800 |
| commit | 0bfbe5058d61ae93d82b09f1dff7eb30dc22426e (patch) | |
| tree | 6ccf3dd9c36ff4b1f6cde5edbce21cdf0de78497 /js/tests/unit/bootstrap-modal.js | |
| parent | 43cbc9440425b7c97c943690eefd14520de708e1 (diff) | |
| parent | 4bd1ba4e0dc44d1d16161306576548f378ab1f8a (diff) | |
| download | bootstrap-0bfbe5058d61ae93d82b09f1dff7eb30dc22426e.tar.xz bootstrap-0bfbe5058d61ae93d82b09f1dff7eb30dc22426e.zip | |
Merge branch '2.0-wip'
Conflicts:
.gitignore
LICENSE
Makefile
bootstrap.css
bootstrap.min.css
docs/assets/js/application.js
docs/assets/js/google-code-prettify/prettify.css
docs/index.html
docs/javascript.html
examples/container-app.html
examples/fluid.html
examples/hero.html
js/bootstrap-alerts.js
js/bootstrap-dropdown.js
js/bootstrap-modal.js
js/bootstrap-popover.js
js/bootstrap-scrollspy.js
js/bootstrap-tabs.js
js/bootstrap-twipsy.js
js/tests/index.html
js/tests/unit/bootstrap-modal.js
js/tests/unit/bootstrap-popover.js
js/tests/unit/bootstrap-tabs.js
lib/forms.less
lib/mixins.less
lib/patterns.less
lib/scaffolding.less
lib/tables.less
Diffstat (limited to 'js/tests/unit/bootstrap-modal.js')
| -rw-r--r-- | js/tests/unit/bootstrap-modal.js | 216 |
1 files changed, 75 insertions, 141 deletions
diff --git a/js/tests/unit/bootstrap-modal.js b/js/tests/unit/bootstrap-modal.js index e96f678be..22f5781ea 100644 --- a/js/tests/unit/bootstrap-modal.js +++ b/js/tests/unit/bootstrap-modal.js @@ -1,151 +1,85 @@ $(function () { - module("bootstrap-modal") + module("bootstrap-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 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, 'div element returned') - }) + 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 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 - var div = $("<div id='modal-test'></div>") - div - .modal() - .bind("shown", function () { - ok($('#modal-test').length, 'modal insterted into dom') - start() - div.remove() - }) - .modal("show") - }) + 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 hide modal when hide is called", function () { - stop() - $.support.transition = false - var div = $("<div id='modal-test'></div>") - div - .modal() - .bind("shown", function () { - ok($('#modal-test').is(":visible"), 'modal visible') - ok($('#modal-test').length, 'modal insterted into dom') - div.modal("hide") - }) - .bind("hidden", function() { - ok(!$('#modal-test').is(":visible"), 'modal hidden') - start() - div.remove() - }) - .modal("show") - }) + test("should hide modal when hide is called", function () { + stop() + $.support.transition = false - test("should toggle when toggle is called", function () { - stop() - $.support.transition = false - var div = $("<div id='modal-test'></div>") - div - .modal() - .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') - start() - div.remove() - }) - .modal("toggle") - }) + $("<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 remove from dom when click .close", function () { - stop() - $.support.transition = false - var div = $("<div id='modal-test'><span class='close'></span></div>") - div - .modal() - .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') - start() - div.remove() - }) - .modal("toggle") - }) + 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 add backdrop when desired", function () { - stop() - $.support.transition = false - var div = $("<div id='modal-test'></div>") - div - .modal({ backdrop:true }) - .bind("shown", function () { - equal($('.modal-backdrop').length, 1, 'modal backdrop inserted into dom') - start() - div.remove() - $('.modal-backdrop').remove() - }) - .modal("show") - }) - - test("should not add backdrop when not desired", function () { - stop() - $.support.transition = false - var div = $("<div id='modal-test'></div>") - div - .modal({backdrop:false}) - .bind("shown", function () { - equal($('.modal-backdrop').length, 0, 'modal backdrop not inserted into dom') - start() - div.remove() - }) - .modal("show") - }) - - test("should close backdrop when clicked", function () { - stop() - $.support.transition = false - var div = $("<div id='modal-test'></div>") - div - .modal({backdrop:true}) - .bind("shown", function () { - equal($('.modal-backdrop').length, 1, 'modal backdrop inserted into dom') - $('.modal-backdrop').click() - equal($('.modal-backdrop').length, 0, 'modal backdrop removed from dom') - start() - div.remove() - }) - .modal("show") - }) - - test("should not close backdrop when click disabled", function () { - stop() - $.support.transition = false - var div = $("<div id='modal-test'></div>") - div - .modal({backdrop: 'static'}) - .bind("shown", function () { - equal($('.modal-backdrop').length, 1, 'modal backdrop inserted into dom') - $('.modal-backdrop').click() - equal($('.modal-backdrop').length, 1, 'modal backdrop still in dom') - start() - div.remove() - $('.modal-backdrop').remove() - }) - .modal("show") - }) -}) + 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") + }) +})
\ No newline at end of file |
