1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,52 @@ |
1 |
+$(function () { |
|
2 |
+ |
|
3 |
+ module("bootstrap-dropdowns") |
|
4 |
+ |
|
5 |
+ test("should be defined on jquery object", function () { |
|
6 |
+ ok($(document.body).dropdown, 'dropdown method is defined') |
|
7 |
+ }) |
|
8 |
+ |
|
9 |
+ test("should return element", function () { |
|
10 |
+ ok($(document.body).dropdown()[0] == document.body, 'document.body returned') |
|
11 |
+ }) |
|
12 |
+ |
|
13 |
+ test("should add class open to menu if clicked", function () { |
|
14 |
+ var dropdownHTML = '<ul class="tabs">' |
|
15 |
+ + '<li class="dropdown">' |
|
16 |
+ + '<a href="#" class="dropdown-toggle">Dropdown</a>' |
|
17 |
+ + '<ul class="dropdown-menu">' |
|
18 |
+ + '<li><a href="#">Secondary link</a></li>' |
|
19 |
+ + '<li><a href="#">Something else here</a></li>' |
|
20 |
+ + '<li class="divider"></li>' |
|
21 |
+ + '<li><a href="#">Another link</a></li>' |
|
22 |
+ + '</ul>' |
|
23 |
+ + '</li>' |
|
24 |
+ + '</ul>' |
|
25 |
+ , dropdown = $(dropdownHTML).dropdown() |
|
26 |
+ |
|
27 |
+ dropdown.find('.dropdown-toggle').click() |
|
28 |
+ ok(dropdown.find('.dropdown').hasClass('open'), 'open class added on click') |
|
29 |
+ }) |
|
30 |
+ |
|
31 |
+ test("should remove open class if body clicked", function () { |
|
32 |
+ var dropdownHTML = '<ul class="tabs">' |
|
33 |
+ + '<li class="dropdown">' |
|
34 |
+ + '<a href="#" class="dropdown-toggle">Dropdown</a>' |
|
35 |
+ + '<ul class="dropdown-menu">' |
|
36 |
+ + '<li><a href="#">Secondary link</a></li>' |
|
37 |
+ + '<li><a href="#">Something else here</a></li>' |
|
38 |
+ + '<li class="divider"></li>' |
|
39 |
+ + '<li><a href="#">Another link</a></li>' |
|
40 |
+ + '</ul>' |
|
41 |
+ + '</li>' |
|
42 |
+ + '</ul>' |
|
43 |
+ , dropdown = $(dropdownHTML).dropdown().appendTo('#qunit-runoff') |
|
44 |
+ |
|
45 |
+ dropdown.find('.dropdown-toggle').click() |
|
46 |
+ ok(dropdown.find('.dropdown').hasClass('open'), 'open class added on click') |
|
47 |
+ $('body').click() |
|
48 |
+ ok(!dropdown.find('.dropdown').hasClass('open'), 'open class removed') |
|
49 |
+ dropdown.remove() |
|
50 |
+ }) |
|
51 |
+ |
|
52 |
+}) |
|
0 | 53 |
\ No newline at end of file |