1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,77 @@ |
1 |
+$(function () { |
|
2 |
+ |
|
3 |
+ module("bootstrap-tabs") |
|
4 |
+ |
|
5 |
+ test("should be defined on jquery object", function () { |
|
6 |
+ ok($(document.body).tabs, 'tabs method is defined') |
|
7 |
+ }) |
|
8 |
+ |
|
9 |
+ test("should return element", function () { |
|
10 |
+ ok($(document.body).tabs()[0] == document.body, 'document.body returned') |
|
11 |
+ }) |
|
12 |
+ |
|
13 |
+ test("should activate element by tab id", function () { |
|
14 |
+ var $tabsHTML = $('<ul class="tabs">' |
|
15 |
+ + '<li class="active"><a href="#home">Home</a></li>' |
|
16 |
+ + '<li><a href="#profile">Profile</a></li>' |
|
17 |
+ + '</ul>') |
|
18 |
+ |
|
19 |
+ |
|
20 |
+ $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-runoff") |
|
21 |
+ |
|
22 |
+ $tabsHTML.tabs().find('a').last().click() |
|
23 |
+ equals($("#qunit-runoff").find('.active').attr('id'), "profile") |
|
24 |
+ |
|
25 |
+ $tabsHTML.tabs().find('a').first().click() |
|
26 |
+ equals($("#qunit-runoff").find('.active').attr('id'), "home") |
|
27 |
+ |
|
28 |
+ $("#qunit-runoff").empty() |
|
29 |
+ }) |
|
30 |
+ |
|
31 |
+ test("should activate element by pill id", function () { |
|
32 |
+ var $pillsHTML = $('<ul class="pills">' |
|
33 |
+ + '<li class="active"><a href="#home">Home</a></li>' |
|
34 |
+ + '<li><a href="#profile">Profile</a></li>' |
|
35 |
+ + '</ul>') |
|
36 |
+ |
|
37 |
+ |
|
38 |
+ $('<ul><li id="home"></li><li id="profile"></li></ul>').appendTo("#qunit-runoff") |
|
39 |
+ |
|
40 |
+ $pillsHTML.pills().find('a').last().click() |
|
41 |
+ equals($("#qunit-runoff").find('.active').attr('id'), "profile") |
|
42 |
+ |
|
43 |
+ $pillsHTML.pills().find('a').first().click() |
|
44 |
+ equals($("#qunit-runoff").find('.active').attr('id'), "home") |
|
45 |
+ |
|
46 |
+ $("#qunit-runoff").empty() |
|
47 |
+ }) |
|
48 |
+ |
|
49 |
+ test( "should trigger change event on activate", function () { |
|
50 |
+ var $tabsHTML = $('<ul class="tabs">' |
|
51 |
+ + '<li class="active"><a href="#home">Home</a></li>' |
|
52 |
+ + '<li><a href="#profile">Profile</a></li>' |
|
53 |
+ + '</ul>') |
|
54 |
+ , $target |
|
55 |
+ , count = 0 |
|
56 |
+ , relatedTarget |
|
57 |
+ , target |
|
58 |
+ |
|
59 |
+ $tabsHTML |
|
60 |
+ .tabs() |
|
61 |
+ .bind( "change", function (e) { |
|
62 |
+ target = e.target |
|
63 |
+ relatedTarget = e.relatedTarget |
|
64 |
+ count++ |
|
65 |
+ }) |
|
66 |
+ |
|
67 |
+ $target = $tabsHTML |
|
68 |
+ .find('a') |
|
69 |
+ .last() |
|
70 |
+ .click() |
|
71 |
+ |
|
72 |
+ equals(relatedTarget, $tabsHTML.find('a').first()[0]) |
|
73 |
+ equals(target, $target[0]) |
|
74 |
+ equals(count, 1) |
|
75 |
+ }) |
|
76 |
+ |
|
77 |
+}) |
|
0 | 78 |
\ No newline at end of file |