From 5f4e30ed1d33f83b0fad3afc9174e193e6c3fdf4 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 9 Sep 2011 22:47:49 -0700 Subject: move js plugins to root dir, begin writing tests, and change modal plugin to be more boss like --- js/tests/unit/bootstrap-dropdown.js | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 js/tests/unit/bootstrap-dropdown.js (limited to 'js/tests/unit/bootstrap-dropdown.js') 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 = '' + , 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 = '' + , 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 -- cgit v1.2.3