From: Scott González Date: Tue, 25 Jan 2011 01:35:58 +0000 (-0500) Subject: Accordion tests: Cleaned up deprecated tests. X-Git-Tag: 1.9m4~38^2~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=25f420eb9a82dcecc6da8357454cdc3c3327c4d1;p=jquery-ui.git Accordion tests: Cleaned up deprecated tests. --- diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js index 2fa3ca41a..a0ca3f634 100644 --- a/tests/unit/accordion/accordion_deprecated.js +++ b/tests/unit/accordion/accordion_deprecated.js @@ -1,104 +1,100 @@ -/* - * accordion_core.js - */ - - -(function($) { - -module("accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() ); - -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: "h3: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 h3:last") }); - state(ac, 0, 0, 1); - ac.accordion("activate", $("#list1 h3:first")); - state(ac, 1, 0, 0); - ac.accordion("activate", $("#list1 h3")[1]); - state(ac, 0, 1, 0); -}); - -test("{ active: Selector }", function() { +(function( $ ) { + +module( "accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() ); + +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, numeric, collapsible:true", function() { + var ac = $( "#list1" ).accordion({ collapsible: true }); + 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, 0, 0 ); +}); + +test( "activate, boolean, collapsible: true", function() { + var ac = $( "#list1" ).accordion({ collapsible: true }); + ac.accordion( "activate", 2 ); + state( ac, 0, 0, 1 ); + ac.accordion( "activate", false ); + state( ac, 0, 0, 0 ); +}); + +test( "activate, boolean, collapsible: false", function() { + var ac = $( "#list1" ).accordion(); + ac.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: "h3: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 h3:last" ) }); + state( ac, 0, 0, 1 ); + ac.accordion( "activate", $( "#list1 h3:first" ) ); + state( ac, 1, 0, 0 ); + ac.accordion( "activate", $( "#list1 h3" )[ 1 ] ); + state( ac, 0, 1, 0 ); +}); + +test( "{ active: Selector }", function() { var ac = $("#list1").accordion({ active: "h3:last" }); - state(ac, 0, 0, 1); - ac.accordion('option', 'active', "h3:eq(1)"); - state(ac, 0, 1, 0); + state( ac, 0, 0, 1 ); + ac.accordion( "option", "active", "h3:eq(1)" ); + state( ac, 0, 1, 0 ); }); -test("{ active: Element }", function() { - var ac = $("#list1").accordion({ - active: $("#list1 h3:last")[0] +test( "{ active: Element }", function() { + var ac = $( "#list1" ).accordion({ + active: $( "#list1 h3:last" )[ 0 ] }); - state(ac, 0, 0, 1); - ac.accordion('option', 'active', $("#list1 h3:eq(1)")[0]); - state(ac, 0, 1, 0); + state( ac, 0, 0, 1 ); + ac.accordion( "option", "active", $( "#list1 h3:eq(1)" )[ 0 ] ); + state( ac, 0, 1, 0 ); }); -test("{ active: jQuery Object }", function() { - var ac = $("#list1").accordion({ - active: $("#list1 h3:last") +test( "{ active: jQuery Object }", function() { + var ac = $( "#list1" ).accordion({ + active: $( "#list1 h3:last" ) }); - state(ac, 0, 0, 1); - ac.accordion('option', 'active', $("#list1 h3:eq(1)")); - state(ac, 0, 1, 0); + state( ac, 0, 0, 1 ); + ac.accordion( "option", "active", $( "#list1 h3:eq(1)" ) ); + 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); }); @@ -113,42 +109,67 @@ test("{ autoHeight: false }", function() { ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] ); }); -// fillSpace: false == autoHeight: true, covered above -test("{ fillSpace: true }", function() { - $("#navigationWrapper").height(500); - equalHeights($('#navigation').accordion({ fillSpace: true }), 446, 458); -}); - -test("{ fillSpace: true } with sibling", function() { - $("#navigationWrapper").height(500); - var sibling = $("

Lorem Ipsum

"); - $("#navigationWrapper").prepend( sibling.height(100) ); - //sibling.outerHeight(true) == 126 - equalHeights($('#navigation').accordion({ fillSpace: true}), 320, 332); -}); - -test("{ fillSpace: true } with multiple siblings", function() { - $("#navigationWrapper").height(500); - var sibling = $("

Lorem Ipsum

"); - $("#navigationWrapper") - .prepend( sibling.clone().height(100) ) - .prepend( sibling.clone().height(100).css( "position", "absolute" ) ) - .prepend( sibling.clone().height(50) ); - //sibling.outerHeight(true) == 126 - equalHeights($('#navigation').accordion({ fillSpace: true}), 244, 256); -}); - - - - -module("accordion (deprecated) - icons", accordionSetupTeardown() ); - -test("change headerSelected option after creation", function() { - var list = $("#list1"); - list.accordion( { icons: { "activeHeader": "test" } } ); - equals( $( "#list1 span.test" ).length, 1); - list.accordion( "option", "icons", { "headerSelected": "deprecated" } ); - equals( $( "#list1 span.deprecated" ).length, 1); +test( "{ fillSpace: true }", function() { + $( "#navigationWrapper" ).height( 500 ); + var ac = $( "#navigation" ).accordion({ fillSpace: true }); + equalHeights( ac, 446, 458 ); +}); + +test( "{ fillSapce: true } with sibling", function() { + $( "#navigationWrapper" ).height( 500 ); + $( "

Lorem Ipsum

" ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30 + }) + .prependTo( "#navigationWrapper" ); + var ac = $( "#navigation" ).accordion({ fillSpace: true }); + equalHeights( ac , 346, 358); +}); + +test( "{ fillSpace: true } with multiple siblings", function() { + $( "#navigationWrapper" ).height( 500 ); + $( "

Lorem Ipsum

" ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30 + }) + .prependTo( "#navigationWrapper" ); + $( "

Lorem Ipsum

" ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30, + position: "absolute" + }) + .prependTo( "#navigationWrapper" ); + $( "

Lorem Ipsum

" ) + .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( "icons, headerSelected", function() { + var list = $( "#list1" ).accordion({ + icons: { headerSelected: "a1", header: "h1" } + }); + 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() ); -test("{ navigation: true, navigationFilter: header }", function() { - $("#navigation").accordion({ +test( "{ navigation: true, navigationFilter: header }", function() { + var ac = $( "#navigation" ).accordion({ navigation: true, 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() { - $("#navigation").accordion({ +test( "{ navigation: true, navigationFilter: content }", function() { + var ac = $("#navigation").accordion({ navigation: true, navigationFilter: function() { 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); diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 0e02f0372..1a7b9550d 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -137,12 +137,48 @@ test( "{ heightStyle: 'content' }", function() { test( "{ heightStyle: 'fill' }", function() { $( "#navigationWrapper" ).height( 500 ); var ac = $( "#navigation" ).accordion({ heightStyle: "fill" }); - equalHeights( ac, 446, 458); - ac.accordion( "destroy" ); + equalHeights( ac, 446, 458 ); +}); - $( "
" ).height( 100 ).appendTo( "#navigationWrapper" ); - ac.accordion({ heightStyle: "fill" }); - equalHeights( ac, 346, 358 ); +test( "{ heightStyle: 'fill' } with sibling", function() { + $( "#navigationWrapper" ).height( 500 ); + $( "

Lorem Ipsum

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

Lorem Ipsum

" ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30 + }) + .prependTo( "#navigationWrapper" ); + $( "

Lorem Ipsum

" ) + .css({ + height: 50, + marginTop: 20, + marginBottom: 30, + position: "absolute" + }) + .prependTo( "#navigationWrapper" ); + $( "

Lorem Ipsum

" ) + .css({ + height: 25, + marginTop: 10, + marginBottom: 15 + }) + .prependTo( "#navigationWrapper" ); + var ac = $( "#navigation" ).accordion({ heightStyle: "fill" }); + equalHeights( ac, 296, 308 ); }); test( "{ icons: false }", function() {