diff options
| author | Jacob Thornton <[email protected]> | 2011-09-09 22:47:49 -0700 |
|---|---|---|
| committer | Jacob Thornton <[email protected]> | 2011-09-09 22:47:49 -0700 |
| commit | 5f4e30ed1d33f83b0fad3afc9174e193e6c3fdf4 (patch) | |
| tree | 105cd02ae9923fb2171f695e261e5311c81786b3 /js/tests/unit | |
| parent | df3ca4d94a69436c1d6c53f5559aefca98fb2232 (diff) | |
| download | bootstrap-5f4e30ed1d33f83b0fad3afc9174e193e6c3fdf4.tar.xz bootstrap-5f4e30ed1d33f83b0fad3afc9174e193e6c3fdf4.zip | |
move js plugins to root dir, begin writing tests, and change modal plugin to be more boss like
Diffstat (limited to 'js/tests/unit')
| -rw-r--r-- | js/tests/unit/bootstrap-alerts.js | 41 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-dropdown.js | 52 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-modal.js | 32 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-popover.js | 0 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-tabs.js | 0 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-twipsy.js | 0 |
6 files changed, 125 insertions, 0 deletions
diff --git a/js/tests/unit/bootstrap-alerts.js b/js/tests/unit/bootstrap-alerts.js new file mode 100644 index 000000000..152d97ab7 --- /dev/null +++ b/js/tests/unit/bootstrap-alerts.js @@ -0,0 +1,41 @@ +$(function () { + + module("bootstrap-alerts") + + test("should be defined on jquery object", function () { + ok($(document.body).alert, 'alert method is defined') + }) + + test("should return element", function () { + ok($(document.body).alert()[0] == document.body, 'document.body returned') + }) + + test("should fade element out on clicking .close", function () { + var alertHTML = '<div class="alert-message warning fade in">' + + '<a class="close" href="#">×</a>' + + '<p><strong>Holy guacamole!</strong> Best check yo self, you’re not looking too good.</p>' + + '</div>' + , alert = $(alertHTML).alert() + + alert.find('.close').click() + + ok(!alert.hasClass('in'), 'remove .in class on .close click') + }) + + test("should remove element when clicking .close", function () { + $.support.transition = false + + var alertHTML = '<div class="alert-message warning fade in">' + + '<a class="close" href="#">×</a>' + + '<p><strong>Holy guacamole!</strong> Best check yo self, you’re not looking too good.</p>' + + '</div>' + , alert = $(alertHTML).appendTo('#qunit-runoff').alert() + + ok($('#qunit-runoff').find('.alert-message').length, 'element added to dom') + + alert.find('.close').click() + + ok(!$('#qunit-runoff').find('.alert-message').length, 'element removed from dom') + }) + +})
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-dropdown.js b/js/tests/unit/bootstrap-dropdown.js new file mode 100644 index 000000000..2c2acb9bb --- /dev/null +++ b/js/tests/unit/bootstrap-dropdown.js @@ -0,0 +1,52 @@ +$(function () { + + module("bootstrap-dropdowns") + + test("should be defined on jquery object", function () { + ok($(document.body).dropdown, 'dropdown method is defined') + }) + + test("should return element", function () { + ok($(document.body).dropdown()[0] == document.body, 'document.body returned') + }) + + test("should add class open to menu if clicked", function () { + var dropdownHTML = '<ul class="tabs">' + + '<li class="dropdown">' + + '<a href="#" class="dropdown-toggle">Dropdown</a>' + + '<ul class="dropdown-menu">' + + '<li><a href="#">Secondary link</a></li>' + + '<li><a href="#">Something else here</a></li>' + + '<li class="divider"></li>' + + '<li><a href="#">Another link</a></li>' + + '</ul>' + + '</li>' + + '</ul>' + , dropdown = $(dropdownHTML).dropdown() + + dropdown.find('.dropdown-toggle').click() + ok(dropdown.find('.dropdown').hasClass('open'), 'open class added on click') + }) + + test("should remove open class if body clicked", function () { + var dropdownHTML = '<ul class="tabs">' + + '<li class="dropdown">' + + '<a href="#" class="dropdown-toggle">Dropdown</a>' + + '<ul class="dropdown-menu">' + + '<li><a href="#">Secondary link</a></li>' + + '<li><a href="#">Something else here</a></li>' + + '<li class="divider"></li>' + + '<li><a href="#">Another link</a></li>' + + '</ul>' + + '</li>' + + '</ul>' + , dropdown = $(dropdownHTML).dropdown().appendTo('#qunit-runoff') + + dropdown.find('.dropdown-toggle').click() + ok(dropdown.find('.dropdown').hasClass('open'), 'open class added on click') + $('body').click() + ok(!dropdown.find('.dropdown').hasClass('open'), 'open class removed') + dropdown.remove() + }) + +})
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-modal.js b/js/tests/unit/bootstrap-modal.js new file mode 100644 index 000000000..24510664c --- /dev/null +++ b/js/tests/unit/bootstrap-modal.js @@ -0,0 +1,32 @@ +$(function () { + + module("bootstrap-modal") + + test("should be defined on jquery object", function () { + ok($(document.body).modal, 'modal method is defined') + }) + + test("should not return element", function () { + ok(!$(document.body).modal()[0], 'document.body not returned') + }) + + test("should return instance of modal class", function () { + ok($(document.body).modal() instanceof $.fn.modal.Modal, 'document.body returned') + }) + + test("should expose defaults var for settings", { + ok(!!$.fn.modal.default, 'default object exposed') + }) + + test("should insert into dom when open is called", function () { + var div = $("<div></div>") + div.modal().open() + }) + + test("should remove from dom when close is called", function () { + $.support.transition = false + re + }) + + test("should remove from dom when click .close") +})
\ No newline at end of file diff --git a/js/tests/unit/bootstrap-popover.js b/js/tests/unit/bootstrap-popover.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/tests/unit/bootstrap-popover.js diff --git a/js/tests/unit/bootstrap-tabs.js b/js/tests/unit/bootstrap-tabs.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/tests/unit/bootstrap-tabs.js diff --git a/js/tests/unit/bootstrap-twipsy.js b/js/tests/unit/bootstrap-twipsy.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/tests/unit/bootstrap-twipsy.js |
