Skip to content
Permalink
Browse files

Accordion tests: Cleanup.

  • Loading branch information
scottgonzalez committed Jun 13, 2011
1 parent 2bc6627 commit e549e18fc2f658fe15c53c1df84847c00e87c9de
@@ -27,7 +27,7 @@
}).get();
deepEqual( actual, expected );
}
function equalHeights( accordion, min, max ) {
function accordion_equalHeights( accordion, min, max ) {
var sizes = [];
accordion.find( ".ui-accordion-content" ).each(function() {
sizes.push( $( this ).outerHeight() );
@@ -3,6 +3,7 @@
module( "accordion: core", accordionSetupTeardown() );

$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
expect( 4 );
test( "markup structure: " + type, function() {
var element = $( selector ).accordion();
ok( element.hasClass( "ui-accordion" ), "main element is .ui-accordion" );
@@ -17,6 +18,7 @@ $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( typ
});

test( "handle click on header-descendant", function() {
expect( 1 );
var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).click();
accordion_state( element, 0, 1, 0 );
@@ -24,7 +24,7 @@
}).get();
deepEqual( actual, expected );
}
function equalHeights( accordion, min, max ) {
function accordion_equalHeights( accordion, min, max ) {
var sizes = [];
accordion.find( ".ui-accordion-content" ).each(function() {
sizes.push( $( this ).outerHeight() );
@@ -3,6 +3,7 @@
module( "accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() );

test( "activate, numeric", function() {
expect( 5 );
var element = $( "#list1" ).accordion({ active: 1 });
accordion_state( element, 0, 1, 0 );
element.accordion( "activate", 2 );
@@ -16,6 +17,7 @@ test( "activate, numeric", function() {
});

test( "activate, numeric, collapsible:true", function() {
expect( 3 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
accordion_state( element, 0, 0, 1 );
@@ -26,6 +28,7 @@ test( "activate, numeric, collapsible:true", function() {
});

test( "activate, boolean, collapsible: true", function() {
expect( 2 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
accordion_state( element, 0, 0, 1 );
@@ -34,6 +37,7 @@ test( "activate, boolean, collapsible: true", function() {
});

test( "activate, boolean, collapsible: false", function() {
expect( 2 );
var element = $( "#list1" ).accordion();
element.accordion( "activate", 2 );
accordion_state( element, 0, 0, 1 );
@@ -42,6 +46,7 @@ test( "activate, boolean, collapsible: false", function() {
});

test( "activate, string expression", function() {
expect( 4 );
var element = $( "#list1" ).accordion({ active: "h3:last" });
accordion_state( element, 0, 0, 1 );
element.accordion( "activate", ":first" );
@@ -53,6 +58,7 @@ test( "activate, string expression", function() {
});

test( "activate, jQuery or DOM element", function() {
expect( 3 );
var element = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) });
accordion_state( element, 0, 0, 1 );
element.accordion( "activate", $( "#list1 h3:first" ) );
@@ -62,6 +68,7 @@ test( "activate, jQuery or DOM element", function() {
});

test( "{ active: Selector }", function() {
expect( 2 );
var element = $("#list1").accordion({
active: "h3:last"
});
@@ -71,6 +78,7 @@ test( "{ active: Selector }", function() {
});

test( "{ active: Element }", function() {
expect( 2 );
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )[ 0 ]
});
@@ -80,6 +88,7 @@ test( "{ active: Element }", function() {
});

test( "{ active: jQuery Object }", function() {
expect( 2 );
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )
});
@@ -95,27 +104,31 @@ test( "{ active: jQuery Object }", function() {
module( "accordion (deprecated) - height options", accordionSetupTeardown() );

test( "{ autoHeight: true }, default", function() {
equalHeights($('#navigation').accordion({ autoHeight: true }), 95, 130);
expect( 3 );
accordion_equalHeights( $( "#navigation" ).accordion({ autoHeight: true }), 95, 130 );
});

test("{ autoHeight: false }", function() {
var element = $('#navigation').accordion({ autoHeight: false });
test( "{ autoHeight: false }", function() {
expect( 3 );
var element = $( "#navigation" ).accordion({ autoHeight: false });
var sizes = [];
element.find(".ui-accordion-content").each(function() {
sizes.push($(this).height());
element.find( ".ui-accordion-content" ).each(function() {
sizes.push( $(this).height() );
});
ok( sizes[0] >= 70 && sizes[0] <= 105, "was " + sizes[0] );
ok( sizes[1] >= 98 && sizes[1] <= 126, "was " + sizes[1] );
ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] );
});

test( "{ fillSpace: true }", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeights( element, 446, 458 );
accordion_equalHeights( element, 446, 458 );
});

test( "{ fillSapce: true } with sibling", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
@@ -125,10 +138,11 @@ test( "{ fillSapce: true } with sibling", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeights( element , 346, 358);
accordion_equalHeights( element , 346, 358);
});

test( "{ fillSpace: true } with multiple siblings", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
$( "<p>Lorem Ipsum</p>" )
.css({
@@ -153,7 +167,7 @@ test( "{ fillSpace: true } with multiple siblings", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
equalHeights( element, 296, 308 );
accordion_equalHeights( element, 296, 308 );
});


@@ -163,6 +177,7 @@ test( "{ fillSpace: true } with multiple siblings", function() {
module( "accordion (deprecated) - icons", accordionSetupTeardown() );

test( "icons, headerSelected", function() {
expect( 3 );
var element = $( "#list1" ).accordion({
icons: { headerSelected: "a1", header: "h1" }
});
@@ -179,18 +194,19 @@ test( "icons, headerSelected", function() {
module( "accordion (deprecated) - resize", accordionSetupTeardown() );

test( "resize", function() {
expect( 6 );
var element = $( "#navigation" )
.parent()
.height( 300 )
.end()
.accordion({
heightStyle: "fill"
});
equalHeights( element, 246, 258 );
accordion_equalHeights( element, 246, 258 );

element.parent().height( 500 );
element.accordion( "resize" );
equalHeights( element, 446, 458 );
accordion_equalHeights( element, 446, 458 );
});


@@ -200,6 +216,7 @@ test( "resize", function() {
module( "accordion (deprecated) - navigation", accordionSetupTeardown() );

test( "{ navigation: true, navigationFilter: header }", function() {
expect( 2 );
var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
@@ -211,10 +228,11 @@ test( "{ navigation: true, navigationFilter: header }", function() {
});

test( "{ navigation: true, navigationFilter: content }", function() {
var element = $("#navigation").accordion({
expect( 2 );
var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
return /\?p=1\.1\.3\.2$/.test(this.href);
return /\?p=1\.1\.3\.2$/.test( this.href );
}
});
equal( element.accordion( "option", "active" ), 2 );
@@ -3,13 +3,15 @@
module( "accordion: methods", accordionSetupTeardown() );

test( "destroy", function() {
domEqual("#list1", function() {
$("#list1").accordion().accordion("destroy");
expect( 1 );
domEqual( "#list1", function() {
$( "#list1" ).accordion().accordion( "destroy" );
});
});

test( "enable/disable", function() {
var element = $('#list1').accordion();
expect( 3 );
var element = $( "#list1" ).accordion();
accordion_state( element, 1, 0, 0 );
element.accordion( "disable" );
element.accordion( "option", "active", 1 );
@@ -20,18 +22,19 @@ test( "enable/disable", function() {
});

test( "refresh", function() {
expect( 6 );
var element = $( "#navigation" )
.parent()
.height( 300 )
.end()
.accordion({
heightStyle: "fill"
});
equalHeights( element, 246, 258 );
accordion_equalHeights( element, 246, 258 );

element.parent().height( 500 );
element.accordion( "refresh" );
equalHeights( element, 446, 458 );
accordion_equalHeights( element, 446, 458 );
});

}( jQuery ) );

0 comments on commit e549e18

Please sign in to comment.
You can’t perform that action at this time.