diff options
| author | Jacob Thornton <[email protected]> | 2012-03-24 18:20:09 -0700 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2012-03-24 18:20:09 -0700 |
| commit | bccc2cb7191eb54a4d67563625a748d7ecd381d4 (patch) | |
| tree | c4562643867c197b7f7f5792694e3e10aab8de52 /js/tests | |
| parent | ef5ac02b698ffab3a42d21f20859b70df85543c0 (diff) | |
| download | bootstrap-bccc2cb7191eb54a4d67563625a748d7ecd381d4.tar.xz bootstrap-bccc2cb7191eb54a4d67563625a748d7ecd381d4.zip | |
add preventDefault support for all inital event types (show, close, hide, etc.) + fix small bug with scrollspy.last
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/index.html | 2 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-alert.js | 15 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-carousel.js | 28 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-collapse.js | 15 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-tab.js | 16 |
5 files changed, 76 insertions, 0 deletions
diff --git a/js/tests/index.html b/js/tests/index.html index 2d59ab032..3e6cb9777 100644 --- a/js/tests/index.html +++ b/js/tests/index.html @@ -15,6 +15,7 @@ <script src="../../js/bootstrap-transition.js"></script> <script src="../../js/bootstrap-alert.js"></script> <script src="../../js/bootstrap-button.js"></script> + <script src="../../js/bootstrap-carousel.js"></script> <script src="../../js/bootstrap-collapse.js"></script> <script src="../../js/bootstrap-dropdown.js"></script> <script src="../../js/bootstrap-modal.js"></script> @@ -28,6 +29,7 @@ <script src="unit/bootstrap-transition.js"></script> <script src="unit/bootstrap-alert.js"></script> <script src="unit/bootstrap-button.js"></script> + <script src="unit/bootstrap-carousel.js"></script> <script src="unit/bootstrap-collapse.js"></script> <script src="unit/bootstrap-dropdown.js"></script> <script src="unit/bootstrap-modal.js"></script> diff --git a/js/tests/unit/bootstrap-alert.js b/js/tests/unit/bootstrap-alert.js index e607f4340..7f24e0e6b 100644 --- a/js/tests/unit/bootstrap-alert.js +++ b/js/tests/unit/bootstrap-alert.js @@ -38,4 +38,19 @@ $(function () { ok(!$('#qunit-fixture').find('.alert-message').length, 'element removed from dom') }) + test("should not fire closed when close is prevented", function () { + $.support.transition = false + stop(); + $('<div class="alert"/>') + .bind('close', function (e) { + e.preventDefault(); + ok(true); + start(); + }) + .bind('closed', function () { + ok(false); + }) + .alert('close') + }) + })
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-carousel.js b/js/tests/unit/bootstrap-carousel.js new file mode 100644 index 000000000..92c23e227 --- /dev/null +++ b/js/tests/unit/bootstrap-carousel.js @@ -0,0 +1,28 @@ +$(function () { + + module("bootstrap-carousel") + + test("should be defined on jquery object", function () { + ok($(document.body).carousel, 'carousel method is defined') + }) + + test("should return element", function () { + ok($(document.body).carousel()[0] == document.body, 'document.body returned') + }) + + test("should not fire sliden when slide is prevented", function () { + $.support.transition = false + stop(); + $('<div class="carousel"/>') + .bind('slide', function (e) { + e.preventDefault(); + ok(true); + start(); + }) + .bind('slid', function () { + ok(false); + }) + .carousel('next') + }) + +})
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-collapse.js b/js/tests/unit/bootstrap-collapse.js index 698238d96..8e52898b5 100644 --- a/js/tests/unit/bootstrap-collapse.js +++ b/js/tests/unit/bootstrap-collapse.js @@ -22,4 +22,19 @@ $(function () { ok(/height/.test(el.attr('style')), 'has height set') }) + test("should not fire shown when show is prevented", function () { + $.support.transition = false + stop(); + $('<div class="collapse"/>') + .bind('show', function (e) { + e.preventDefault(); + ok(true); + start(); + }) + .bind('shown', function () { + ok(false); + }) + .collapse('show') + }) + })
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-tab.js b/js/tests/unit/bootstrap-tab.js index 18f490fa5..987804781 100644 --- a/js/tests/unit/bootstrap-tab.js +++ b/js/tests/unit/bootstrap-tab.js @@ -42,4 +42,20 @@ $(function () { equals($("#qunit-fixture").find('.active').attr('id'), "home") }) + + test("should not fire closed when close is prevented", function () { + $.support.transition = false + stop(); + $('<div class="tab"/>') + .bind('show', function (e) { + e.preventDefault(); + ok(true); + start(); + }) + .bind('shown', function () { + ok(false); + }) + .tab('show') + }) + })
\ No newline at end of file |
