diff options
Diffstat (limited to 'js/tests')
| -rw-r--r-- | js/tests/unit/dropdown.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js index 09b5673a4..e45bd0a46 100644 --- a/js/tests/unit/dropdown.js +++ b/js/tests/unit/dropdown.js @@ -149,4 +149,71 @@ $(function () { $("#qunit-fixture").html("") }) + test("should fire show and hide event", function () { + var dropdownHTML = '<ul class="tabs">' + + '<li class="dropdown">' + + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">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) + .appendTo('#qunit-fixture') + .find('[data-toggle="dropdown"]') + .dropdown() + + stop() + + dropdown + .parent('.dropdown') + .bind('show.bs.dropdown', function () { + ok(true, 'show was called') + }) + .bind('hide.bs.dropdown', function () { + ok(true, 'hide was called') + start() + }) + + dropdown.click() + $(document.body).click() + }) + + + test("should fire shown and hiden event", function () { + var dropdownHTML = '<ul class="tabs">' + + '<li class="dropdown">' + + '<a href="#" class="dropdown-toggle" data-toggle="dropdown">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) + .appendTo('#qunit-fixture') + .find('[data-toggle="dropdown"]') + .dropdown() + + stop() + + dropdown + .parent('.dropdown') + .bind('shown.bs.dropdown', function () { + ok(true, 'show was called') + }) + .bind('hidden.bs.dropdown', function () { + ok(true, 'hide was called') + start() + }) + + dropdown.click() + $(document.body).click() + }) + }) |
