mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Accordion tests: Cleaned up deprecated tests.
This commit is contained in:
parent
5ed1046a4a
commit
25f420eb9a
@ -1,104 +1,100 @@
|
|||||||
/*
|
(function( $ ) {
|
||||||
* accordion_core.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
module( "accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() );
|
||||||
|
|
||||||
(function($) {
|
test( "activate, numeric", function() {
|
||||||
|
var ac = $( "#list1" ).accordion({ active: 1 });
|
||||||
module("accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() );
|
state( ac, 0, 1, 0 );
|
||||||
|
ac.accordion( "activate", 2 );
|
||||||
test("activate", function() {
|
state( ac, 0, 0, 1 );
|
||||||
var expected = $('#list1').accordion(),
|
ac.accordion( "activate", 0 );
|
||||||
actual = expected.accordion('activate', 2);
|
state( ac, 1, 0, 0 );
|
||||||
equals(actual, expected, 'activate is chainable');
|
ac.accordion( "activate", 1 );
|
||||||
|
state( ac, 0, 1, 0 );
|
||||||
|
ac.accordion( "activate", 2 );
|
||||||
|
state( ac, 0, 0, 1 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("activate, numeric", function() {
|
test( "activate, numeric, collapsible:true", function() {
|
||||||
var ac = $('#list1').accordion({ active: 1 });
|
var ac = $( "#list1" ).accordion({ collapsible: true });
|
||||||
state(ac, 0, 1, 0);
|
ac.accordion( "activate", 2 );
|
||||||
ac.accordion("activate", 2);
|
state( ac, 0, 0, 1 );
|
||||||
state(ac, 0, 0, 1);
|
ac.accordion( "activate", 0 );
|
||||||
ac.accordion("activate", 0);
|
state( ac, 1, 0, 0 );
|
||||||
state(ac, 1, 0, 0);
|
ac.accordion( "activate", -1 );
|
||||||
ac.accordion("activate", 1);
|
state( ac, 0, 0, 0 );
|
||||||
state(ac, 0, 1, 0);
|
|
||||||
ac.accordion("activate", 2);
|
|
||||||
state(ac, 0, 0, 1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("activate, boolean and numeric, collapsible:true", function() {
|
test( "activate, boolean, collapsible: true", function() {
|
||||||
var ac = $('#list1').accordion({collapsible: true}).accordion("activate", 2);
|
var ac = $( "#list1" ).accordion({ collapsible: true });
|
||||||
state(ac, 0, 0, 1);
|
ac.accordion( "activate", 2 );
|
||||||
ok("x", "----");
|
state( ac, 0, 0, 1 );
|
||||||
ac.accordion("activate", 0);
|
ac.accordion( "activate", false );
|
||||||
state(ac, 1, 0, 0);
|
state( ac, 0, 0, 0 );
|
||||||
ok("x", "----");
|
|
||||||
ac.accordion("activate", -1);
|
|
||||||
state(ac, 0, 0, 0);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("activate, boolean, collapsible: false", function() {
|
test( "activate, boolean, collapsible: false", function() {
|
||||||
var ac = $('#list1').accordion().accordion("activate", 2);
|
var ac = $( "#list1" ).accordion();
|
||||||
state(ac, 0, 0, 1);
|
ac.accordion( "activate", 2 );
|
||||||
ac.accordion("activate", false);
|
state( ac, 0, 0, 1 );
|
||||||
state(ac, 0, 0, 1);
|
ac.accordion( "activate", false );
|
||||||
|
state( ac, 0, 0, 1 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("activate, string expression", function() {
|
test( "activate, string expression", function() {
|
||||||
var ac = $('#list1').accordion({ active: "h3:last" });
|
var ac = $( "#list1" ).accordion({ active: "h3:last" });
|
||||||
state(ac, 0, 0, 1);
|
state( ac, 0, 0, 1 );
|
||||||
ac.accordion("activate", ":first");
|
ac.accordion( "activate", ":first" );
|
||||||
state(ac, 1, 0, 0);
|
state( ac, 1, 0, 0 );
|
||||||
ac.accordion("activate", ":eq(1)");
|
ac.accordion( "activate", ":eq(1)" );
|
||||||
state(ac, 0, 1, 0);
|
state( ac, 0, 1, 0 );
|
||||||
ac.accordion("activate", ":last");
|
ac.accordion( "activate", ":last" );
|
||||||
state(ac, 0, 0, 1);
|
state( ac, 0, 0, 1 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("activate, jQuery or DOM element", function() {
|
test( "activate, jQuery or DOM element", function() {
|
||||||
var ac = $('#list1').accordion({ active: $("#list1 h3:last") });
|
var ac = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) });
|
||||||
state(ac, 0, 0, 1);
|
state( ac, 0, 0, 1 );
|
||||||
ac.accordion("activate", $("#list1 h3:first"));
|
ac.accordion( "activate", $( "#list1 h3:first" ) );
|
||||||
state(ac, 1, 0, 0);
|
state( ac, 1, 0, 0 );
|
||||||
ac.accordion("activate", $("#list1 h3")[1]);
|
ac.accordion( "activate", $( "#list1 h3" )[ 1 ] );
|
||||||
state(ac, 0, 1, 0);
|
state( ac, 0, 1, 0 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("{ active: Selector }", function() {
|
test( "{ active: Selector }", function() {
|
||||||
var ac = $("#list1").accordion({
|
var ac = $("#list1").accordion({
|
||||||
active: "h3:last"
|
active: "h3:last"
|
||||||
});
|
});
|
||||||
state(ac, 0, 0, 1);
|
state( ac, 0, 0, 1 );
|
||||||
ac.accordion('option', 'active', "h3:eq(1)");
|
ac.accordion( "option", "active", "h3:eq(1)" );
|
||||||
state(ac, 0, 1, 0);
|
state( ac, 0, 1, 0 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("{ active: Element }", function() {
|
test( "{ active: Element }", function() {
|
||||||
var ac = $("#list1").accordion({
|
var ac = $( "#list1" ).accordion({
|
||||||
active: $("#list1 h3:last")[0]
|
active: $( "#list1 h3:last" )[ 0 ]
|
||||||
});
|
});
|
||||||
state(ac, 0, 0, 1);
|
state( ac, 0, 0, 1 );
|
||||||
ac.accordion('option', 'active', $("#list1 h3:eq(1)")[0]);
|
ac.accordion( "option", "active", $( "#list1 h3:eq(1)" )[ 0 ] );
|
||||||
state(ac, 0, 1, 0);
|
state( ac, 0, 1, 0 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("{ active: jQuery Object }", function() {
|
test( "{ active: jQuery Object }", function() {
|
||||||
var ac = $("#list1").accordion({
|
var ac = $( "#list1" ).accordion({
|
||||||
active: $("#list1 h3:last")
|
active: $( "#list1 h3:last" )
|
||||||
});
|
});
|
||||||
state(ac, 0, 0, 1);
|
state( ac, 0, 0, 1 );
|
||||||
ac.accordion('option', 'active', $("#list1 h3:eq(1)"));
|
ac.accordion( "option", "active", $( "#list1 h3:eq(1)" ) );
|
||||||
state(ac, 0, 1, 0);
|
state( ac, 0, 1, 0 );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module( "accordion (deprecated) - height options", accordionSetupTeardown() );
|
||||||
|
|
||||||
module("accordion (deprecated) - height options", accordionSetupTeardown() );
|
test( "{ autoHeight: true }, default", function() {
|
||||||
|
|
||||||
test("{ autoHeight: true }, default", function() {
|
|
||||||
equalHeights($('#navigation').accordion({ autoHeight: true }), 95, 130);
|
equalHeights($('#navigation').accordion({ autoHeight: true }), 95, 130);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -113,42 +109,67 @@ test("{ autoHeight: false }", function() {
|
|||||||
ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] );
|
ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] );
|
||||||
});
|
});
|
||||||
|
|
||||||
// fillSpace: false == autoHeight: true, covered above
|
test( "{ fillSpace: true }", function() {
|
||||||
test("{ fillSpace: true }", function() {
|
$( "#navigationWrapper" ).height( 500 );
|
||||||
$("#navigationWrapper").height(500);
|
var ac = $( "#navigation" ).accordion({ fillSpace: true });
|
||||||
equalHeights($('#navigation').accordion({ fillSpace: true }), 446, 458);
|
equalHeights( ac, 446, 458 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("{ fillSpace: true } with sibling", function() {
|
test( "{ fillSapce: true } with sibling", function() {
|
||||||
$("#navigationWrapper").height(500);
|
$( "#navigationWrapper" ).height( 500 );
|
||||||
var sibling = $("<p>Lorem Ipsum</p>");
|
$( "<p>Lorem Ipsum</p>" )
|
||||||
$("#navigationWrapper").prepend( sibling.height(100) );
|
.css({
|
||||||
//sibling.outerHeight(true) == 126
|
height: 50,
|
||||||
equalHeights($('#navigation').accordion({ fillSpace: true}), 320, 332);
|
marginTop: 20,
|
||||||
|
marginBottom: 30
|
||||||
|
})
|
||||||
|
.prependTo( "#navigationWrapper" );
|
||||||
|
var ac = $( "#navigation" ).accordion({ fillSpace: true });
|
||||||
|
equalHeights( ac , 346, 358);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("{ fillSpace: true } with multiple siblings", function() {
|
test( "{ fillSpace: true } with multiple siblings", function() {
|
||||||
$("#navigationWrapper").height(500);
|
$( "#navigationWrapper" ).height( 500 );
|
||||||
var sibling = $("<p>Lorem Ipsum</p>");
|
$( "<p>Lorem Ipsum</p>" )
|
||||||
$("#navigationWrapper")
|
.css({
|
||||||
.prepend( sibling.clone().height(100) )
|
height: 50,
|
||||||
.prepend( sibling.clone().height(100).css( "position", "absolute" ) )
|
marginTop: 20,
|
||||||
.prepend( sibling.clone().height(50) );
|
marginBottom: 30
|
||||||
//sibling.outerHeight(true) == 126
|
})
|
||||||
equalHeights($('#navigation').accordion({ fillSpace: true}), 244, 256);
|
.prependTo( "#navigationWrapper" );
|
||||||
|
$( "<p>Lorem Ipsum</p>" )
|
||||||
|
.css({
|
||||||
|
height: 50,
|
||||||
|
marginTop: 20,
|
||||||
|
marginBottom: 30,
|
||||||
|
position: "absolute"
|
||||||
|
})
|
||||||
|
.prependTo( "#navigationWrapper" );
|
||||||
|
$( "<p>Lorem Ipsum</p>" )
|
||||||
|
.css({
|
||||||
|
height: 25,
|
||||||
|
marginTop: 10,
|
||||||
|
marginBottom: 15
|
||||||
|
})
|
||||||
|
.prependTo( "#navigationWrapper" );
|
||||||
|
var ac = $( "#navigation" ).accordion({ fillSpace: true });
|
||||||
|
equalHeights( ac, 296, 308 );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module("accordion (deprecated) - icons", accordionSetupTeardown() );
|
|
||||||
|
|
||||||
test("change headerSelected option after creation", function() {
|
module( "accordion (deprecated) - icons", accordionSetupTeardown() );
|
||||||
var list = $("#list1");
|
|
||||||
list.accordion( { icons: { "activeHeader": "test" } } );
|
test( "icons, headerSelected", function() {
|
||||||
equals( $( "#list1 span.test" ).length, 1);
|
var list = $( "#list1" ).accordion({
|
||||||
list.accordion( "option", "icons", { "headerSelected": "deprecated" } );
|
icons: { headerSelected: "a1", header: "h1" }
|
||||||
equals( $( "#list1 span.deprecated" ).length, 1);
|
});
|
||||||
|
ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
|
||||||
|
list.accordion( "option", "icons", { headerSelected: "a2", header: "h2" } );
|
||||||
|
ok( !list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
|
||||||
|
ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -175,26 +196,29 @@ test( "resize", function() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module( "accordion (deprecated) - navigation", accordionSetupTeardown() );
|
module( "accordion (deprecated) - navigation", accordionSetupTeardown() );
|
||||||
|
|
||||||
test("{ navigation: true, navigationFilter: header }", function() {
|
test( "{ navigation: true, navigationFilter: header }", function() {
|
||||||
$("#navigation").accordion({
|
var ac = $( "#navigation" ).accordion({
|
||||||
navigation: true,
|
navigation: true,
|
||||||
navigationFilter: function() {
|
navigationFilter: function() {
|
||||||
return /\?p=1\.1\.3$/.test(this.href);
|
return /\?p=1\.1\.3$/.test( this.href );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
|
equal( ac.accordion( "option", "active" ), 2 );
|
||||||
|
state( ac, 0, 0, 1 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test("{ navigation: true, navigationFilter: content }", function() {
|
test( "{ navigation: true, navigationFilter: content }", function() {
|
||||||
$("#navigation").accordion({
|
var ac = $("#navigation").accordion({
|
||||||
navigation: true,
|
navigation: true,
|
||||||
navigationFilter: function() {
|
navigationFilter: function() {
|
||||||
return /\?p=1\.1\.3\.2$/.test(this.href);
|
return /\?p=1\.1\.3\.2$/.test(this.href);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
|
equal( ac.accordion( "option", "active" ), 2 );
|
||||||
|
state( ac, 0, 0, 1 );
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -137,12 +137,48 @@ test( "{ heightStyle: 'content' }", function() {
|
|||||||
test( "{ heightStyle: 'fill' }", function() {
|
test( "{ heightStyle: 'fill' }", function() {
|
||||||
$( "#navigationWrapper" ).height( 500 );
|
$( "#navigationWrapper" ).height( 500 );
|
||||||
var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
|
var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
|
||||||
equalHeights( ac, 446, 458);
|
equalHeights( ac, 446, 458 );
|
||||||
ac.accordion( "destroy" );
|
});
|
||||||
|
|
||||||
$( "<div>" ).height( 100 ).appendTo( "#navigationWrapper" );
|
test( "{ heightStyle: 'fill' } with sibling", function() {
|
||||||
ac.accordion({ heightStyle: "fill" });
|
$( "#navigationWrapper" ).height( 500 );
|
||||||
equalHeights( ac, 346, 358 );
|
$( "<p>Lorem Ipsum</p>" )
|
||||||
|
.css({
|
||||||
|
height: 50,
|
||||||
|
marginTop: 20,
|
||||||
|
marginBottom: 30
|
||||||
|
})
|
||||||
|
.prependTo( "#navigationWrapper" );
|
||||||
|
var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
|
||||||
|
equalHeights( ac , 346, 358);
|
||||||
|
});
|
||||||
|
|
||||||
|
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
|
||||||
|
$( "#navigationWrapper" ).height( 500 );
|
||||||
|
$( "<p>Lorem Ipsum</p>" )
|
||||||
|
.css({
|
||||||
|
height: 50,
|
||||||
|
marginTop: 20,
|
||||||
|
marginBottom: 30
|
||||||
|
})
|
||||||
|
.prependTo( "#navigationWrapper" );
|
||||||
|
$( "<p>Lorem Ipsum</p>" )
|
||||||
|
.css({
|
||||||
|
height: 50,
|
||||||
|
marginTop: 20,
|
||||||
|
marginBottom: 30,
|
||||||
|
position: "absolute"
|
||||||
|
})
|
||||||
|
.prependTo( "#navigationWrapper" );
|
||||||
|
$( "<p>Lorem Ipsum</p>" )
|
||||||
|
.css({
|
||||||
|
height: 25,
|
||||||
|
marginTop: 10,
|
||||||
|
marginBottom: 15
|
||||||
|
})
|
||||||
|
.prependTo( "#navigationWrapper" );
|
||||||
|
var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
|
||||||
|
equalHeights( ac, 296, 308 );
|
||||||
});
|
});
|
||||||
|
|
||||||
test( "{ icons: false }", function() {
|
test( "{ icons: false }", function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user