diff options
| author | Nick Veys <[email protected]> | 2011-09-17 14:47:38 -0500 |
|---|---|---|
| committer | Nick Veys <[email protected]> | 2011-09-17 15:08:16 -0500 |
| commit | 2cb233319da422c9f003e8687d686e96a92be489 (patch) | |
| tree | 99622a861da1dc4bc0905f1fe6055fc10f630d45 /js/tests | |
| parent | 732ff9ed1c0b590c17951de412024cb7acd5763a (diff) | |
| download | bootstrap-2cb233319da422c9f003e8687d686e96a92be489.tar.xz bootstrap-2cb233319da422c9f003e8687d686e96a92be489.zip | |
Adding flag to prevent backdrop click hiding modal
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/bootstrap-modal.js | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/js/tests/unit/bootstrap-modal.js b/js/tests/unit/bootstrap-modal.js index 4bbb3313c..69e720f0f 100644 --- a/js/tests/unit/bootstrap-modal.js +++ b/js/tests/unit/bootstrap-modal.js @@ -86,4 +86,66 @@ $(function () { }) .modal("toggle") }) -})
\ No newline at end of file + + test("should add backdrop when desired", function () { + stop() + $.support.transition = false + var div = $("<div id='modal-test'></div>") + div + .modal({backdrop:true}) + .modal("show") + .bind("shown", function () { + equal($('.modal-backdrop').length, 1, 'modal backdrop inserted into dom') + start() + div.remove() + $('.modal-backdrop').remove() + }) + }) + + test("should not add backdrop when not desired", function () { + stop() + $.support.transition = false + var div = $("<div id='modal-test'></div>") + div + .modal({backdrop:false}) + .modal("show") + .bind("shown", function () { + equal($('.modal-backdrop').length, 0, 'modal backdrop not inserted into dom') + start() + div.remove() + }) + }) + + test("should close backdrop when clicked", function () { + stop() + $.support.transition = false + var div = $("<div id='modal-test'></div>") + div + .modal({backdrop:true}) + .modal("show") + .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() + }) + }) + + test("should not close backdrop when click disabled", function () { + stop() + $.support.transition = false + var div = $("<div id='modal-test'></div>") + div + .modal({backdrop:true, backdropClickHides:false}) + .modal("show") + .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() + }) + }) +}) |
