1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/*
* accordion_methods.js
*/
(function($) {
module("accordion: methods");
test("init", function() {
$("<div></div>").appendTo('body').accordion().remove();
ok(true, '.accordion() called on element');
$([]).accordion().remove();
ok(true, '.accordion() called on empty collection');
$('<div></div>').accordion().remove();
ok(true, '.accordion() called on disconnected DOMElement - never connected');
$('<div></div>').appendTo('body').remove().accordion().remove();
ok(true, '.accordion() called on disconnected DOMElement - removed');
$('<div></div>').accordion().accordion("foo").remove();
ok(true, 'arbitrary method called after init');
var el = $('<div></div>').accordion();
var foo = el.accordion("option", "foo");
el.remove();
ok(true, 'arbitrary option getter after init');
$('<div></div>').accordion().accordion("option", "foo", "bar").remove();
ok(true, 'arbitrary option setter after init');
});
test("destroy", function() {
var beforeHtml = $("#list1").find("div").css("font-style", "normal").end().parent().html();
var afterHtml = $("#list1").accordion().accordion("destroy").parent().html();
// Opera 9 outputs role="" instead of removing the attribute like everyone else
if ($.browser.opera) {
afterHtml = afterHtml.replace(/ role=""/g, "");
}
equal( afterHtml, beforeHtml );
});
test("enable", function() {
var expected = $('#list1').accordion(),
actual = expected.accordion('enable');
equals(actual, expected, 'enable is chainable');
state(expected, 1, 0, 0)
});
test("disable", function() {
var expected = $('#list1').accordion(),
actual = expected.accordion('disable');
equals(actual, expected, 'disable is chainable');
state(expected, 1, 0, 0)
expected.accordion("activate", 1);
state(expected, 1, 0, 0)
expected.accordion("enable");
expected.accordion("activate", 1);
state(expected, 0, 1, 0)
});
test("activate", function() {
var expected = $('#list1').accordion(),
actual = expected.accordion('activate', 2);
equals(actual, expected, 'activate is chainable');
});
test("activate, numeric", function() {
var ac = $('#list1').accordion({ active: 1 });
state(ac, 0, 1, 0);
ac.accordion("activate", 2);
state(ac, 0, 0, 1);
ac.accordion("activate", 0);
state(ac, 1, 0, 0);
ac.accordion("activate", 1);
state(ac, 0, 1, 0);
ac.accordion("activate", 2);
state(ac, 0, 0, 1);
});
test("activate, boolean and numeric, collapsible:true", function() {
var ac = $('#list1').accordion({collapsible: true}).accordion("activate", 2);
state(ac, 0, 0, 1);
ok("x", "----");
ac.accordion("activate", 0);
state(ac, 1, 0, 0);
ok("x", "----");
ac.accordion("activate", -1);
state(ac, 0, 0, 0);
});
test("activate, boolean, collapsible: false", function() {
var ac = $('#list1').accordion().accordion("activate", 2);
state(ac, 0, 0, 1);
ac.accordion("activate", false);
state(ac, 0, 0, 1);
});
test("activate, string expression", function() {
var ac = $('#list1').accordion({ active: "a:last" });
state(ac, 0, 0, 1);
ac.accordion("activate", ":first");
state(ac, 1, 0, 0);
ac.accordion("activate", ":eq(1)");
state(ac, 0, 1, 0);
ac.accordion("activate", ":last");
state(ac, 0, 0, 1);
});
test("activate, jQuery or DOM element", function() {
var ac = $('#list1').accordion({ active: $("#list1 a:last") });
state(ac, 0, 0, 1);
ac.accordion("activate", $("#list1 a:first"));
state(ac, 1, 0, 0);
ac.accordion("activate", $("#list1 a")[1]);
state(ac, 0, 1, 0);
});
test("resize", function() {
var expected = $('#navigation').parent().height(300).end().accordion({
fillSpace: true
});
equalHeights(expected, 246, 258);
expected.parent().height(500);
expected.accordion("resize");
equalHeights(expected, 446, 458);
});
})(jQuery);
|