From: Scott González Date: Mon, 13 Jun 2011 18:51:13 +0000 (-0400) Subject: Accordion tests: Cleanup. X-Git-Tag: 1.9m6~98^2~32 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e549e18fc2f658fe15c53c1df84847c00e87c9de;p=jquery-ui.git Accordion tests: Cleanup. --- diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index ef20c057e..c4eee6b4c 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -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() ); diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js index 000470d0b..ec4ca29d5 100644 --- a/tests/unit/accordion/accordion_core.js +++ b/tests/unit/accordion/accordion_core.js @@ -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 ); diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html index 2e754fe6a..5bfe7562b 100644 --- a/tests/unit/accordion/accordion_deprecated.html +++ b/tests/unit/accordion/accordion_deprecated.html @@ -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() ); diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js index 733cb82b0..3a2075b2b 100644 --- a/tests/unit/accordion/accordion_deprecated.js +++ b/tests/unit/accordion/accordion_deprecated.js @@ -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,14 +104,16 @@ 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] ); @@ -110,12 +121,14 @@ test("{ autoHeight: false }", function() { }); 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 ); $( "

Lorem Ipsum

" ) .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 ); $( "

Lorem Ipsum

" ) .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,6 +194,7 @@ test( "icons, headerSelected", function() { module( "accordion (deprecated) - resize", accordionSetupTeardown() ); test( "resize", function() { + expect( 6 ); var element = $( "#navigation" ) .parent() .height( 300 ) @@ -186,11 +202,11 @@ test( "resize", function() { .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 ); diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index d45bde134..c6ba3230a 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -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,6 +22,7 @@ test( "enable/disable", function() { }); test( "refresh", function() { + expect( 6 ); var element = $( "#navigation" ) .parent() .height( 300 ) @@ -27,11 +30,11 @@ test( "refresh", function() { .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 ) ); diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 57762dec8..80b7f0b39 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -3,12 +3,14 @@ module( "accordion: options", accordionSetupTeardown() ); test( "{ active: default }", function() { + expect( 2 ); var element = $( "#list1" ).accordion(); equal( element.accordion( "option", "active" ), 0 ); accordion_state( element, 1, 0, 0 ); }); test( "{ active: false }", function() { + expect( 7 ); var element = $( "#list1" ).accordion({ active: false, collapsible: true @@ -30,6 +32,7 @@ test( "{ active: false }", function() { }); test( "{ active: Number }", function() { + expect( 8 ); var element = $( "#list1" ).accordion({ active: 2 }); @@ -51,6 +54,7 @@ test( "{ active: Number }", function() { if ( $.uiBackCompat === false ) { test( "{ active: -Number }", function() { + expect( 8 ); var element = $( "#list1" ).accordion({ active: -1 }); @@ -74,6 +78,7 @@ if ( $.uiBackCompat === false ) { // TODO: add animation tests test( "{ collapsible: false }", function() { + expect( 4 ); var element = $( "#list1" ).accordion({ active: 1 }); @@ -87,6 +92,7 @@ test( "{ collapsible: false }", function() { }); test( "{ collapsible: true }", function() { + expect( 6 ); var element = $( "#list1" ).accordion({ active: 1, collapsible: true @@ -106,6 +112,7 @@ test( "{ collapsible: true }", function() { }); test( "{ event: null }", function() { + expect( 5 ); var element = $( "#list1" ).accordion({ event: null }); @@ -122,6 +129,7 @@ test( "{ event: null }", function() { }); test( "{ event: custom }", function() { + expect( 11 ); var element = $( "#list1" ).accordion({ event: "custom1 custom2" }); @@ -153,6 +161,7 @@ test( "{ event: custom }", function() { }); test( "{ header: default }", function() { + expect( 2 ); // default: > li > :first-child,> :not(li):even // > :not(li):even accordion_state( $( "#list1" ).accordion(), 1, 0, 0); @@ -161,6 +170,7 @@ test( "{ header: default }", function() { }); test( "{ header: custom }", function() { + expect( 6 ); var element = $( "#navigationWrapper" ).accordion({ header: "h2" }); @@ -174,11 +184,13 @@ test( "{ header: custom }", function() { }); test( "{ heightStyle: 'auto' }", function() { + expect( 3 ); var element = $( "#navigation" ).accordion({ heightStyle: "auto" }); - equalHeights( element, 95, 130 ); + accordion_equalHeights( element, 95, 130 ); }); test( "{ heightStyle: 'content' }", function() { + expect( 3 ); var element = $( "#navigation" ).accordion({ heightStyle: "content" }); var sizes = element.find( ".ui-accordion-content" ).map(function() { return $( this ).height(); @@ -189,12 +201,14 @@ test( "{ heightStyle: 'content' }", function() { }); test( "{ heightStyle: 'fill' }", function() { + expect( 3 ); $( "#navigationWrapper" ).height( 500 ); var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); - equalHeights( element, 446, 458 ); + accordion_equalHeights( element, 446, 458 ); }); test( "{ heightStyle: 'fill' } with sibling", function() { + expect( 3 ); $( "#navigationWrapper" ).height( 500 ); $( "

Lorem Ipsum

" ) .css({ @@ -204,10 +218,11 @@ test( "{ heightStyle: 'fill' } with sibling", function() { }) .prependTo( "#navigationWrapper" ); var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); - equalHeights( element , 346, 358); + accordion_equalHeights( element , 346, 358); }); test( "{ heightStyle: 'fill' } with multiple siblings", function() { + expect( 3 ); $( "#navigationWrapper" ).height( 500 ); $( "

Lorem Ipsum

" ) .css({ @@ -232,10 +247,11 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() { }) .prependTo( "#navigationWrapper" ); var element = $( "#navigation" ).accordion({ heightStyle: "fill" }); - equalHeights( element, 296, 308 ); + accordion_equalHeights( element, 296, 308 ); }); test( "{ icons: false }", function() { + expect( 8 ); var element = $( "#list1" ); function icons( on ) { deepEqual( element.find( "span.ui-icon").length, on ? 3 : 0 ); @@ -254,6 +270,7 @@ test( "{ icons: false }", function() { }); test( "{ icons: hash }", function() { + expect( 3 ); var element = $( "#list1" ).accordion({ icons: { activeHeader: "a1", header: "h1" } });