aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-04-15 11:29:26 -0400
committerScott González <scott.gonzalez@gmail.com>2011-04-15 11:29:26 -0400
commit4547da1ba56641a490f03043241003aca505e3e4 (patch)
treea6ed23cb62fa297ff250945a4f1ffa2cbe150c8e
parentae8963f054902b44c8b510ed09ad941eb4e7f64f (diff)
downloadjquery-ui-4547da1ba56641a490f03043241003aca505e3e4.tar.gz
jquery-ui-4547da1ba56641a490f03043241003aca505e3e4.zip
Accordion tests: Coding standards.
-rw-r--r--tests/unit/accordion/accordion.html2
-rw-r--r--tests/unit/accordion/accordion_core.js28
-rw-r--r--tests/unit/accordion/accordion_deprecated.html2
-rw-r--r--tests/unit/accordion/accordion_deprecated.js198
-rw-r--r--tests/unit/accordion/accordion_events.js58
-rw-r--r--tests/unit/accordion/accordion_methods.js26
-rw-r--r--tests/unit/accordion/accordion_options.js222
7 files changed, 268 insertions, 268 deletions
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html
index 8ffdc22a4..c260ef22f 100644
--- a/tests/unit/accordion/accordion.html
+++ b/tests/unit/accordion/accordion.html
@@ -20,7 +20,7 @@
<script src="../testsuite.js"></script>
<script>
- function state( accordion ) {
+ function accordion_state( accordion ) {
var expected = $.makeArray( arguments ).slice( 1 );
var actual = accordion.find( ".ui-accordion-content" ).map(function() {
return $( this ).css( "display" ) === "none" ? 0 : 1;
diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js
index 05479faf9..280339c26 100644
--- a/tests/unit/accordion/accordion_core.js
+++ b/tests/unit/accordion/accordion_core.js
@@ -4,46 +4,46 @@ module( "accordion: core", accordionSetupTeardown() );
$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
test( "markup structure: " + type, function() {
- var ac = $( selector ).accordion();
- ok( ac.hasClass( "ui-accordion" ), "main element is .ui-accordion" );
- equal( ac.find( ".ui-accordion-header" ).length, 3,
+ var element = $( selector ).accordion();
+ ok( element.hasClass( "ui-accordion" ), "main element is .ui-accordion" );
+ equal( element.find( ".ui-accordion-header" ).length, 3,
".ui-accordion-header elements exist, correct number" );
- equal( ac.find( ".ui-accordion-content" ).length, 3,
+ equal( element.find( ".ui-accordion-content" ).length, 3,
".ui-accordion-content elements exist, correct number" );
- same( ac.find( ".ui-accordion-header" ).next().get(),
- ac.find( ".ui-accordion-content" ).get(),
+ same( element.find( ".ui-accordion-header" ).next().get(),
+ element.find( ".ui-accordion-content" ).get(),
"content panels come immediately after headers" );
});
});
test( "handle click on header-descendant", function() {
- var ac = $( "#navigation" ).accordion();
+ var element = $( "#navigation" ).accordion();
$( "#navigation h2:eq(1) a" ).click();
- state( ac, 0, 1, 0 );
+ accordion_state( element, 0, 1, 0 );
});
test( "ui-accordion-heading class added to headers anchor", function() {
expect( 1 );
- var ac = $( "#list1" ).accordion();
- var anchors = $( ".ui-accordion-heading" );
+ var element = $( "#list1" ).accordion();
+ var anchors = element.find( ".ui-accordion-heading" );
equals( anchors.length, 3 );
});
test( "accessibility", function () {
expect( 13 );
- var ac = $( "#list1" ).accordion().accordion( "option", "active", 1 );
- var headers = $( ".ui-accordion-header" );
+ var element = $( "#list1" ).accordion().accordion( "option", "active", 1 );
+ var headers = element.find( ".ui-accordion-header" );
equals( headers.eq( 1 ).attr( "tabindex" ), 0, "active header should have tabindex=0" );
equals( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header should have tabindex=-1" );
- equals( ac.attr( "role" ), "tablist", "main role" );
+ equals( element.attr( "role" ), "tablist", "main role" );
equals( headers.attr( "role" ), "tab", "tab roles" );
equals( headers.next().attr( "role" ), "tabpanel", "tabpanel roles" );
equals( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded" );
equals( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded" );
equals( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
equals( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected" );
- ac.accordion( "option", "active", 0 );
+ element.accordion( "option", "active", 0 );
equals( headers.eq( 0 ).attr( "aria-expanded" ), "true", "newly active tab has aria-expanded" );
equals( headers.eq( 1 ).attr( "aria-expanded" ), "false", "newly inactive tab has aria-expanded" );
equals( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected" );
diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html
index 38b1bda04..e8254f4f3 100644
--- a/tests/unit/accordion/accordion_deprecated.html
+++ b/tests/unit/accordion/accordion_deprecated.html
@@ -17,7 +17,7 @@
<script src="../testsuite.js"></script>
<script>
- function state( accordion ) {
+ function accordion_state( accordion ) {
var expected = $.makeArray( arguments ).slice( 1 );
var actual = accordion.find( ".ui-accordion-content" ).map(function() {
return $( this ).css( "display" ) === "none" ? 0 : 1;
diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js
index 636404d18..0435f48a7 100644
--- a/tests/unit/accordion/accordion_deprecated.js
+++ b/tests/unit/accordion/accordion_deprecated.js
@@ -3,89 +3,89 @@
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 );
+ var element = $( "#list1" ).accordion({ active: 1 });
+ accordion_state( element, 0, 1, 0 );
+ element.accordion( "activate", 2 );
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "activate", 0 );
+ accordion_state( element, 1, 0, 0 );
+ element.accordion( "activate", 1 );
+ accordion_state( element, 0, 1, 0 );
+ element.accordion( "activate", 2 );
+ accordion_state( element, 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 );
+ var element = $( "#list1" ).accordion({ collapsible: true });
+ element.accordion( "activate", 2 );
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "activate", 0 );
+ accordion_state( element, 1, 0, 0 );
+ element.accordion( "activate", -1 );
+ accordion_state( element, 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 );
+ var element = $( "#list1" ).accordion({ collapsible: true });
+ element.accordion( "activate", 2 );
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "activate", false );
+ accordion_state( element, 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 );
+ var element = $( "#list1" ).accordion();
+ element.accordion( "activate", 2 );
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "activate", false );
+ accordion_state( element, 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 );
+ var element = $( "#list1" ).accordion({ active: "h3:last" });
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "activate", ":first" );
+ accordion_state( element, 1, 0, 0 );
+ element.accordion( "activate", ":eq(1)" );
+ accordion_state( element, 0, 1, 0 );
+ element.accordion( "activate", ":last" );
+ accordion_state( element, 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 );
+ var element = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) });
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "activate", $( "#list1 h3:first" ) );
+ accordion_state( element, 1, 0, 0 );
+ element.accordion( "activate", $( "#list1 h3" )[ 1 ] );
+ accordion_state( element, 0, 1, 0 );
});
test( "{ active: Selector }", function() {
- var ac = $("#list1").accordion({
+ var element = $("#list1").accordion({
active: "h3:last"
});
- state( ac, 0, 0, 1 );
- ac.accordion( "option", "active", "h3:eq(1)" );
- state( ac, 0, 1, 0 );
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "option", "active", "h3:eq(1)" );
+ accordion_state( element, 0, 1, 0 );
});
test( "{ active: Element }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#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 );
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "option", "active", $( "#list1 h3:eq(1)" )[ 0 ] );
+ accordion_state( element, 0, 1, 0 );
});
test( "{ active: jQuery Object }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )
});
- state( ac, 0, 0, 1 );
- ac.accordion( "option", "active", $( "#list1 h3:eq(1)" ) );
- state( ac, 0, 1, 0 );
+ accordion_state( element, 0, 0, 1 );
+ element.accordion( "option", "active", $( "#list1 h3:eq(1)" ) );
+ accordion_state( element, 0, 1, 0 );
});
@@ -99,9 +99,9 @@ test( "{ autoHeight: true }, default", function() {
});
test("{ autoHeight: false }", function() {
- var accordion = $('#navigation').accordion({ autoHeight: false });
+ var element = $('#navigation').accordion({ autoHeight: false });
var sizes = [];
- accordion.find(".ui-accordion-content").each(function() {
+ element.find(".ui-accordion-content").each(function() {
sizes.push($(this).height());
});
ok( sizes[0] >= 70 && sizes[0] <= 105, "was " + sizes[0] );
@@ -111,8 +111,8 @@ test("{ autoHeight: false }", function() {
test( "{ fillSpace: true }", function() {
$( "#navigationWrapper" ).height( 500 );
- var ac = $( "#navigation" ).accordion({ fillSpace: true });
- equalHeights( ac, 446, 458 );
+ var element = $( "#navigation" ).accordion({ fillSpace: true });
+ equalHeights( element, 446, 458 );
});
test( "{ fillSapce: true } with sibling", function() {
@@ -124,8 +124,8 @@ test( "{ fillSapce: true } with sibling", function() {
marginBottom: 30
})
.prependTo( "#navigationWrapper" );
- var ac = $( "#navigation" ).accordion({ fillSpace: true });
- equalHeights( ac , 346, 358);
+ var element = $( "#navigation" ).accordion({ fillSpace: true });
+ equalHeights( element , 346, 358);
});
test( "{ fillSpace: true } with multiple siblings", function() {
@@ -152,8 +152,8 @@ test( "{ fillSpace: true } with multiple siblings", function() {
marginBottom: 15
})
.prependTo( "#navigationWrapper" );
- var ac = $( "#navigation" ).accordion({ fillSpace: true });
- equalHeights( ac, 296, 308 );
+ var element = $( "#navigation" ).accordion({ fillSpace: true });
+ equalHeights( element, 296, 308 );
});
@@ -163,13 +163,13 @@ test( "{ fillSpace: true } with multiple siblings", function() {
module( "accordion (deprecated) - icons", accordionSetupTeardown() );
test( "icons, headerSelected", function() {
- var list = $( "#list1" ).accordion({
+ var element = $( "#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" ) );
+ ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
+ element.accordion( "option", "icons", { headerSelected: "a2", header: "h2" } );
+ ok( !element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
+ ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) );
});
@@ -179,18 +179,18 @@ test( "icons, headerSelected", function() {
module( "accordion (deprecated) - resize", accordionSetupTeardown() );
test( "resize", function() {
- var expected = $( "#navigation" )
+ var element = $( "#navigation" )
.parent()
.height( 300 )
.end()
.accordion({
heightStyle: "fill"
});
- equalHeights( expected, 246, 258 );
+ equalHeights( element, 246, 258 );
- expected.parent().height( 500 );
- expected.accordion( "resize" );
- equalHeights( expected, 446, 458 );
+ element.parent().height( 500 );
+ element.accordion( "resize" );
+ equalHeights( element, 446, 458 );
});
@@ -200,25 +200,25 @@ test( "resize", function() {
module( "accordion (deprecated) - navigation", accordionSetupTeardown() );
test( "{ navigation: true, navigationFilter: header }", function() {
- var ac = $( "#navigation" ).accordion({
+ var element = $( "#navigation" ).accordion({
navigation: true,
navigationFilter: function() {
return /\?p=1\.1\.3$/.test( this.href );
}
});
- equal( ac.accordion( "option", "active" ), 2 );
- state( ac, 0, 0, 1 );
+ equal( element.accordion( "option", "active" ), 2 );
+ accordion_state( element, 0, 0, 1 );
});
test( "{ navigation: true, navigationFilter: content }", function() {
- var ac = $("#navigation").accordion({
+ var element = $("#navigation").accordion({
navigation: true,
navigationFilter: function() {
return /\?p=1\.1\.3\.2$/.test(this.href);
}
});
- equal( ac.accordion( "option", "active" ), 2 );
- state( ac, 0, 0, 1 );
+ equal( element.accordion( "option", "active" ), 2 );
+ accordion_state( element, 0, 0, 1 );
});
@@ -229,26 +229,26 @@ module( "accordion (deprecated) - changestart/change events", accordionSetupTear
test( "changestart", function() {
expect( 26 );
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: false,
collapsible: true
});
- var headers = ac.find( ".ui-accordion-header" );
- var content = ac.find( ".ui-accordion-content" );
+ var headers = element.find( ".ui-accordion-header" );
+ var content = element.find( ".ui-accordion-content" );
- ac.one( "accordionchangestart", function( event, ui ) {
+ element.one( "accordionchangestart", function( event, ui ) {
equals( ui.oldHeader.size(), 0 );
equals( ui.oldContent.size(), 0 );
equals( ui.newHeader.size(), 1 );
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equals( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
- state( ac, 0, 0, 0 );
+ accordion_state( element, 0, 0, 0 );
});
- ac.accordion( "option", "active", 0 );
- state( ac, 1, 0, 0 );
+ element.accordion( "option", "active", 0 );
+ accordion_state( element, 1, 0, 0 );
- ac.one( "accordionchangestart", function( event, ui ) {
+ element.one( "accordionchangestart", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equals( ui.oldContent.size(), 1 );
@@ -257,34 +257,34 @@ test( "changestart", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equals( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
- state( ac, 1, 0, 0 );
+ accordion_state( element, 1, 0, 0 );
});
headers.eq( 1 ).click();
- state( ac, 0, 1, 0 );
+ accordion_state( element, 0, 1, 0 );
- ac.one( "accordionchangestart", function( event, ui ) {
+ element.one( "accordionchangestart", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equals( ui.oldContent.size(), 1 );
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
equals( ui.newHeader.size(), 0 );
equals( ui.newContent.size(), 0 );
- state( ac, 0, 1, 0 );
+ accordion_state( element, 0, 1, 0 );
});
- ac.accordion( "option", "active", false );
- state( ac, 0, 0, 0 );
+ element.accordion( "option", "active", false );
+ accordion_state( element, 0, 0, 0 );
});
test( "change", function() {
expect( 20 );
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: false,
collapsible: true
});
- var headers = ac.find( ".ui-accordion-header" );
- var content = ac.find( ".ui-accordion-content" );
+ var headers = element.find( ".ui-accordion-header" );
+ var content = element.find( ".ui-accordion-content" );
- ac.one( "accordionchange", function( event, ui ) {
+ element.one( "accordionchange", function( event, ui ) {
equals( ui.oldHeader.size(), 0 );
equals( ui.oldContent.size(), 0 );
equals( ui.newHeader.size(), 1 );
@@ -292,9 +292,9 @@ test( "change", function() {
equals( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
});
- ac.accordion( "option", "active", 0 );
+ element.accordion( "option", "active", 0 );
- ac.one( "accordionchange", function( event, ui ) {
+ element.one( "accordionchange", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equals( ui.oldContent.size(), 1 );
@@ -306,7 +306,7 @@ test( "change", function() {
});
headers.eq( 1 ).click();
- ac.one( "accordionchange", function( event, ui ) {
+ element.one( "accordionchange", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equals( ui.oldContent.size(), 1 );
@@ -314,7 +314,7 @@ test( "change", function() {
equals( ui.newHeader.size(), 0 );
equals( ui.newContent.size(), 0 );
});
- ac.accordion( "option", "active", false );
+ element.accordion( "option", "active", false );
});
})(jQuery);
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index c3ba2e2c1..2438f28ea 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -4,14 +4,14 @@ module( "accordion: events", accordionSetupTeardown() );
test( "beforeActivate", function() {
expect( 38 );
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: false,
collapsible: true
});
- var headers = ac.find( ".ui-accordion-header" );
- var content = ac.find( ".ui-accordion-content" );
+ var headers = element.find( ".ui-accordion-header" );
+ var content = element.find( ".ui-accordion-content" );
- ac.one( "accordionbeforeactivate", function( event, ui ) {
+ element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
equals( ui.oldHeader.size(), 0 );
equals( ui.oldContent.size(), 0 );
@@ -19,12 +19,12 @@ test( "beforeActivate", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equals( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
- state( ac, 0, 0, 0 );
+ accordion_state( element, 0, 0, 0 );
});
- ac.accordion( "option", "active", 0 );
- state( ac, 1, 0, 0 );
+ element.accordion( "option", "active", 0 );
+ accordion_state( element, 1, 0, 0 );
- ac.one( "accordionbeforeactivate", function( event, ui ) {
+ element.one( "accordionbeforeactivate", function( event, ui ) {
equals( event.originalEvent.type, "click" );
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
@@ -34,12 +34,12 @@ test( "beforeActivate", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equals( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
- state( ac, 1, 0, 0 );
+ accordion_state( element, 1, 0, 0 );
});
headers.eq( 1 ).click();
- state( ac, 0, 1, 0 );
+ accordion_state( element, 0, 1, 0 );
- ac.one( "accordionbeforeactivate", function( event, ui ) {
+ element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
@@ -47,12 +47,12 @@ test( "beforeActivate", function() {
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
equals( ui.newHeader.size(), 0 );
equals( ui.newContent.size(), 0 );
- state( ac, 0, 1, 0 );
+ accordion_state( element, 0, 1, 0 );
});
- ac.accordion( "option", "active", false );
- state( ac, 0, 0, 0 );
+ element.accordion( "option", "active", false );
+ accordion_state( element, 0, 0, 0 );
- ac.one( "accordionbeforeactivate", function( event, ui ) {
+ element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
equals( ui.oldHeader.size(), 0 );
equals( ui.oldContent.size(), 0 );
@@ -61,22 +61,22 @@ test( "beforeActivate", function() {
equals( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 2 ] );
event.preventDefault();
- state( ac, 0, 0, 0 );
+ accordion_state( element, 0, 0, 0 );
});
- ac.accordion( "option", "active", 2 );
- state( ac, 0, 0, 0 );
+ element.accordion( "option", "active", 2 );
+ accordion_state( element, 0, 0, 0 );
});
test( "activate", function() {
expect( 21 );
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: false,
collapsible: true
});
- var headers = ac.find( ".ui-accordion-header" );
- var content = ac.find( ".ui-accordion-content" );
+ var headers = element.find( ".ui-accordion-header" );
+ var content = element.find( ".ui-accordion-content" );
- ac.one( "accordionactivate", function( event, ui ) {
+ element.one( "accordionactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 0 );
equals( ui.oldContent.size(), 0 );
equals( ui.newHeader.size(), 1 );
@@ -84,9 +84,9 @@ test( "activate", function() {
equals( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
});
- ac.accordion( "option", "active", 0 );
+ element.accordion( "option", "active", 0 );
- ac.one( "accordionactivate", function( event, ui ) {
+ element.one( "accordionactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 0 ] );
equals( ui.oldContent.size(), 1 );
@@ -98,7 +98,7 @@ test( "activate", function() {
});
headers.eq( 1 ).click();
- ac.one( "accordionactivate", function( event, ui ) {
+ element.one( "accordionactivate", function( event, ui ) {
equals( ui.oldHeader.size(), 1 );
strictEqual( ui.oldHeader[ 0 ], headers[ 1 ] );
equals( ui.oldContent.size(), 1 );
@@ -106,17 +106,17 @@ test( "activate", function() {
equals( ui.newHeader.size(), 0 );
equals( ui.newContent.size(), 0 );
});
- ac.accordion( "option", "active", false );
+ element.accordion( "option", "active", false );
// prevent activation
- ac.one( "accordionbeforeactivate", function( event ) {
+ element.one( "accordionbeforeactivate", function( event ) {
ok( true );
event.preventDefault();
});
- ac.one( "accordionactivate", function() {
+ element.one( "accordionactivate", function() {
ok( false );
});
- ac.accordion( "option", "active", 1 );
+ element.accordion( "option", "active", 1 );
});
}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index eade690b1..d45bde134 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -9,29 +9,29 @@ test( "destroy", function() {
});
test( "enable/disable", function() {
- var accordion = $('#list1').accordion();
- state( accordion, 1, 0, 0 );
- accordion.accordion( "disable" );
- accordion.accordion( "option", "active", 1 );
- state( accordion, 1, 0, 0 );
- accordion.accordion( "enable" );
- accordion.accordion( "option", "active", 1 );
- state( accordion, 0, 1, 0 );
+ var element = $('#list1').accordion();
+ accordion_state( element, 1, 0, 0 );
+ element.accordion( "disable" );
+ element.accordion( "option", "active", 1 );
+ accordion_state( element, 1, 0, 0 );
+ element.accordion( "enable" );
+ element.accordion( "option", "active", 1 );
+ accordion_state( element, 0, 1, 0 );
});
test( "refresh", function() {
- var expected = $( "#navigation" )
+ var element = $( "#navigation" )
.parent()
.height( 300 )
.end()
.accordion({
heightStyle: "fill"
});
- equalHeights( expected, 246, 258 );
+ equalHeights( element, 246, 258 );
- expected.parent().height( 500 );
- expected.accordion( "refresh" );
- equalHeights( expected, 446, 458 );
+ element.parent().height( 500 );
+ element.accordion( "refresh" );
+ equalHeights( element, 446, 458 );
});
}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index 3796d80de..7bd6f2e74 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -3,184 +3,184 @@
module( "accordion: options", accordionSetupTeardown() );
test( "{ active: default }", function() {
- var ac = $( "#list1" ).accordion();
- equals( ac.accordion( "option", "active" ), 0 );
- state( ac, 1, 0, 0 );
+ var element = $( "#list1" ).accordion();
+ equals( element.accordion( "option", "active" ), 0 );
+ accordion_state( element, 1, 0, 0 );
});
test( "{ active: false }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: false,
collapsible: true
});
- state( ac, 0, 0, 0 );
- equals( ac.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
- equals( ac.accordion( "option", "active" ), false );
+ accordion_state( element, 0, 0, 0 );
+ equals( element.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
+ equals( element.accordion( "option", "active" ), false );
- ac.accordion( "option", "collapsible", false );
- state( ac, 1, 0, 0 );
- equals( ac.accordion( "option", "active" ), 0 );
+ element.accordion( "option", "collapsible", false );
+ accordion_state( element, 1, 0, 0 );
+ equals( element.accordion( "option", "active" ), 0 );
- ac.accordion( "destroy" );
- ac.accordion({
+ element.accordion( "destroy" );
+ element.accordion({
active: false
});
- state( ac, 1, 0, 0 );
- strictEqual( ac.accordion( "option", "active" ), 0 );
+ accordion_state( element, 1, 0, 0 );
+ strictEqual( element.accordion( "option", "active" ), 0 );
});
test( "{ active: Number }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: 2
});
- equals( ac.accordion( "option", "active" ), 2 );
- state( ac, 0, 0, 1 );
+ equals( element.accordion( "option", "active" ), 2 );
+ accordion_state( element, 0, 0, 1 );
- ac.accordion( "option", "active", 0 );
- equals( ac.accordion( "option", "active" ), 0 );
- state( ac, 1, 0, 0 );
+ element.accordion( "option", "active", 0 );
+ equals( element.accordion( "option", "active" ), 0 );
+ accordion_state( element, 1, 0, 0 );
- ac.find( ".ui-accordion-header" ).eq( 1 ).click();
- equals( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.find( ".ui-accordion-header" ).eq( 1 ).click();
+ equals( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
- ac.accordion( "option", "active", 10 );
- equals( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.accordion( "option", "active", 10 );
+ equals( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
});
if ( $.uiBackCompat === false ) {
test( "{ active: -Number }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: -1
});
- equals( ac.accordion( "option", "active" ), 2 );
- state( ac, 0, 0, 1 );
+ equals( element.accordion( "option", "active" ), 2 );
+ accordion_state( element, 0, 0, 1 );
- ac.accordion( "option", "active", -2 );
- equals( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.accordion( "option", "active", -2 );
+ equals( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
- ac.accordion( "option", "active", -10 );
- equals( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.accordion( "option", "active", -10 );
+ equals( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
- ac.accordion( "option", "active", -3 );
- equals( ac.accordion( "option", "active" ), 0 );
- state( ac, 1, 0, 0 );
+ element.accordion( "option", "active", -3 );
+ equals( element.accordion( "option", "active" ), 0 );
+ accordion_state( element, 1, 0, 0 );
});
}
// TODO: add animation tests
test( "{ collapsible: false }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: 1
});
- ac.accordion( "option", "active", false );
- equal( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.accordion( "option", "active", false );
+ equal( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
- ac.find( ".ui-accordion-header" ).eq( 1 ).click();
- equal( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.find( ".ui-accordion-header" ).eq( 1 ).click();
+ equal( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
});
test( "{ collapsible: true }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
active: 1,
collapsible: true
});
- ac.accordion( "option", "active", false );
- equal( ac.accordion( "option", "active" ), false );
- state( ac, 0, 0, 0 );
+ element.accordion( "option", "active", false );
+ equal( element.accordion( "option", "active" ), false );
+ accordion_state( element, 0, 0, 0 );
- ac.accordion( "option", "active", 1 );
- equal( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.accordion( "option", "active", 1 );
+ equal( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
- ac.find( ".ui-accordion-header" ).eq( 1 ).click();
- equals( ac.accordion( "option", "active" ), false );
- state( ac, 0, 0, 0 );
+ element.find( ".ui-accordion-header" ).eq( 1 ).click();
+ equals( element.accordion( "option", "active" ), false );
+ accordion_state( element, 0, 0, 0 );
});
test( "{ event: null }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
event: null
});
- state( ac, 1, 0, 0 );
+ accordion_state( element, 1, 0, 0 );
- ac.accordion( "option", "active", 1 );
- equal( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.accordion( "option", "active", 1 );
+ equal( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
// ensure default click handler isn't bound
- ac.find( ".ui-accordion-header" ).eq( 2 ).click();
- equal( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.find( ".ui-accordion-header" ).eq( 2 ).click();
+ equal( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
});
test( "{ event: custom }", function() {
- var ac = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
event: "custom1 custom2"
});
- state( ac, 1, 0, 0 );
+ accordion_state( element, 1, 0, 0 );
- ac.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
- equal( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
+ equal( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
// ensure default click handler isn't bound
- ac.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
- equal( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
+ equal( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
- ac.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
- equal( ac.accordion( "option", "active" ), 2 );
- state( ac, 0, 0, 1 );
+ element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
+ equal( element.accordion( "option", "active" ), 2 );
+ accordion_state( element, 0, 0, 1 );
- ac.accordion( "option", "event", "custom3" );
+ element.accordion( "option", "event", "custom3" );
// ensure old event handlers are unbound
- ac.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
- equal( ac.accordion( "option", "active" ), 2 );
- state( ac, 0, 0, 1 );
+ element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
+ equal( element.accordion( "option", "active" ), 2 );
+ accordion_state( element, 0, 0, 1 );
- ac.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
- equal( ac.accordion( "option", "active" ), 1 );
- state( ac, 0, 1, 0 );
+ element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
+ equal( element.accordion( "option", "active" ), 1 );
+ accordion_state( element, 0, 1, 0 );
});
test( "{ header: default }", function() {
// default: > li > :first-child,> :not(li):even
// > :not(li):even
- state( $( "#list1" ).accordion(), 1, 0, 0);
+ accordion_state( $( "#list1" ).accordion(), 1, 0, 0);
// > li > :first-child
- state( $( "#navigation" ).accordion(), 1, 0, 0);
+ accordion_state( $( "#navigation" ).accordion(), 1, 0, 0);
});
test( "{ header: custom }", function() {
- var ac = $( "#navigationWrapper" ).accordion({
+ var element = $( "#navigationWrapper" ).accordion({
header: "h2"
});
- ac.find( "h2" ).each(function() {
+ element.find( "h2" ).each(function() {
ok( $( this ).hasClass( "ui-accordion-header" ) );
});
- equal( ac.find( ".ui-accordion-header" ).length, 3 );
- state( ac, 1, 0, 0 );
- ac.accordion( "option", "active", 2 );
- state( ac, 0, 0, 1 );
+ equal( element.find( ".ui-accordion-header" ).length, 3 );
+ accordion_state( element, 1, 0, 0 );
+ element.accordion( "option", "active", 2 );
+ accordion_state( element, 0, 0, 1 );
});
test( "{ heightStyle: 'auto' }", function() {
- var ac = $( "#navigation" ).accordion({ heightStyle: "auto" });
- equalHeights( ac, 95, 130 );
+ var element = $( "#navigation" ).accordion({ heightStyle: "auto" });
+ equalHeights( element, 95, 130 );
});
test( "{ heightStyle: 'content' }", function() {
- var ac = $( "#navigation" ).accordion({ heightStyle: "content" });
- var sizes = ac.find( ".ui-accordion-content" ).map(function() {
+ var element = $( "#navigation" ).accordion({ heightStyle: "content" });
+ var sizes = element.find( ".ui-accordion-content" ).map(function() {
return $( this ).height();
}).get();
ok( sizes[ 0 ] >= 70 && sizes[ 0 ] <= 105, "was " + sizes[ 0 ] );
@@ -190,8 +190,8 @@ test( "{ heightStyle: 'content' }", function() {
test( "{ heightStyle: 'fill' }", function() {
$( "#navigationWrapper" ).height( 500 );
- var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
- equalHeights( ac, 446, 458 );
+ var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
+ equalHeights( element, 446, 458 );
});
test( "{ heightStyle: 'fill' } with sibling", function() {
@@ -203,8 +203,8 @@ test( "{ heightStyle: 'fill' } with sibling", function() {
marginBottom: 30
})
.prependTo( "#navigationWrapper" );
- var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
- equalHeights( ac , 346, 358);
+ var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
+ equalHeights( element , 346, 358);
});
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
@@ -231,36 +231,36 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
marginBottom: 15
})
.prependTo( "#navigationWrapper" );
- var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
- equalHeights( ac, 296, 308 );
+ var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
+ equalHeights( element, 296, 308 );
});
test( "{ icons: false }", function() {
- var list = $( "#list1" );
+ var element = $( "#list1" );
function icons( on ) {
- same( list.find( "span.ui-icon").length, on ? 3 : 0 );
- same( list.hasClass( "ui-accordion-icons" ), on );
+ same( element.find( "span.ui-icon").length, on ? 3 : 0 );
+ same( element.hasClass( "ui-accordion-icons" ), on );
}
- list.accordion();
+ element.accordion();
icons( true );
- list.accordion( "destroy" ).accordion({
+ element.accordion( "destroy" ).accordion({
icons: false
});
icons( false );
- list.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } );
+ element.accordion( "option", "icons", { header: "foo", activeHeader: "bar" } );
icons( true );
- list.accordion( "option", "icons", false );
+ element.accordion( "option", "icons", false );
icons( false );
});
test( "{ icons: hash }", function() {
- var list = $( "#list1" ).accordion({
+ var element = $( "#list1" ).accordion({
icons: { activeHeader: "a1", header: "h1" }
});
- ok( list.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
- list.accordion( "option", "icons", { activeHeader: "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" ) );
+ ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
+ element.accordion( "option", "icons", { activeHeader: "a2", header: "h2" } );
+ ok( !element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a1" ) );
+ ok( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ).hasClass( "a2" ) );
});
}( jQuery ) );