2008-05-23 09:14:39 +00:00
|
|
|
module("accordion");
|
|
|
|
|
|
|
|
jQuery.ui.accordion.defaults.animated = false;
|
|
|
|
|
|
|
|
function state(accordion) {
|
|
|
|
var args = $.makeArray(arguments).slice(1);
|
|
|
|
$.each(args, function(i, n) {
|
|
|
|
equals(n, accordion.find("div").eq(i).is(":visible"));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
test("basics", function() {
|
|
|
|
state($('#list1').accordion(), 1, 0, 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("autoheight", function() {
|
2008-05-28 19:35:09 +00:00
|
|
|
$('#navigation').accordion({ header: '.head', autoHeight: false });
|
2008-05-23 09:14:39 +00:00
|
|
|
equals( 90, $('#navigation ul:first').height() );
|
|
|
|
equals( 126, $('#navigation ul:eq(1)').height() );
|
|
|
|
equals( 54, $('#navigation ul:last').height() );
|
2008-05-28 19:35:09 +00:00
|
|
|
$('#navigation').accordion("destroy").accordion({ header: '.head', autoHeight: true });
|
2008-05-23 09:14:39 +00:00
|
|
|
equals( 126, $('#navigation ul:first').height() );
|
|
|
|
equals( 126, $('#navigation ul:eq(1)').height() );
|
|
|
|
equals( 126, $('#navigation ul:last').height() );
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
ac.accordion("activate", -1);
|
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("activate, boolean and numeric, alwaysOpen:false", function() {
|
|
|
|
var ac = $('#list1').accordion({alwaysOpen: false}).accordion("activate", 2);
|
|
|
|
state(ac, 0, 0, 1);
|
2008-05-28 20:04:52 +00:00
|
|
|
ok("x", "----");
|
2008-05-23 09:14:39 +00:00
|
|
|
ac.accordion("activate", 0);
|
|
|
|
state(ac, 1, 0, 0);
|
2008-05-28 20:04:52 +00:00
|
|
|
ok("x", "----");
|
2008-05-23 09:14:39 +00:00
|
|
|
ac.accordion("activate", -1);
|
|
|
|
state(ac, 0, 0, 0);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("activate, boolean, alwaysOpen:true", function() {
|
|
|
|
var ac = $('#list1').accordion().accordion("activate", 2);
|
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
ac.accordion("activate", -1);
|
|
|
|
state(ac, 0, 0, 1);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("activate, string expression", function() {
|
|
|
|
var ac = $('#list1').accordion({ active: ":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);
|
|
|
|
});
|