aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2012-04-19 11:37:33 -0400
committerScott González <scott.gonzalez@gmail.com>2012-04-19 11:37:39 -0400
commit163555d7bf27fe5d272e404de3c4439902710f54 (patch)
tree0c8f8640840bb3c827c9bfc508dad7b813984052
parent0e8d9dde20e6bb4481fbfa94a2066125179066b0 (diff)
downloadjquery-ui-163555d7bf27fe5d272e404de3c4439902710f54.tar.gz
jquery-ui-163555d7bf27fe5d272e404de3c4439902710f54.zip
Accordion tests: Don't polloute the global namespace with helpers.
-rw-r--r--grunt.js4
-rw-r--r--tests/unit/accordion/accordion_core.js7
-rw-r--r--tests/unit/accordion/accordion_deprecated.js94
-rw-r--r--tests/unit/accordion/accordion_events.js21
-rw-r--r--tests/unit/accordion/accordion_methods.js18
-rw-r--r--tests/unit/accordion/accordion_options.js74
-rw-r--r--tests/unit/accordion/accordion_test_helpers.js58
-rw-r--r--tests/unit/testsuite.js2
8 files changed, 149 insertions, 129 deletions
diff --git a/grunt.js b/grunt.js
index a2f47ae51..78303180d 100644
--- a/grunt.js
+++ b/grunt.js
@@ -348,9 +348,6 @@ grunt.initConfig({
}, defaults ),
// TODO: don't create so many globals in tests
globals: {
- accordion_equalHeights: true,
- accordion_setupTeardown: true,
- accordion_state: true,
addMonths: true,
asyncTest: true,
commonWidgetTests: true,
@@ -396,6 +393,7 @@ grunt.initConfig({
tabs_state: true,
tabs_disabled: true,
test: true,
+ TestHelpers: true,
widthAfter: true
}
}
diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js
index b08a5caea..7a1d56c18 100644
--- a/tests/unit/accordion/accordion_core.js
+++ b/tests/unit/accordion/accordion_core.js
@@ -1,6 +1,9 @@
(function( $ ) {
-module( "accordion: core", accordion_setupTeardown() );
+var setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion: core", setupTeardown() );
$.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) {
test( "markup structure: " + type, function() {
@@ -21,7 +24,7 @@ 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 );
+ state( element, 0, 1, 0 );
});
test( "accessibility", function () {
diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js
index 47180e785..8d8e8a0d6 100644
--- a/tests/unit/accordion/accordion_deprecated.js
+++ b/tests/unit/accordion/accordion_deprecated.js
@@ -1,70 +1,74 @@
(function( $ ) {
-module( "accordion (deprecated): expanded active option, activate method", accordion_setupTeardown() );
+var equalHeights = TestHelpers.accordion.equalHeights,
+ setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion (deprecated): expanded active option, activate method", setupTeardown() );
test( "activate, numeric", function() {
expect( 5 );
var element = $( "#list1" ).accordion({ active: 1 });
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "activate", 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "activate, numeric, collapsible:true", function() {
expect( 3 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "activate", -1 );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "activate, boolean, collapsible: true", function() {
expect( 2 );
var element = $( "#list1" ).accordion({ collapsible: true });
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "activate, boolean, collapsible: false", function() {
expect( 2 );
var element = $( "#list1" ).accordion();
element.accordion( "activate", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", false );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "activate, string expression", function() {
expect( 4 );
var element = $( "#list1" ).accordion({ active: "h3:last" });
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", ":first" );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "activate", ":eq(1)" );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "activate", ":last" );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "activate, jQuery or DOM element", function() {
expect( 3 );
var element = $( "#list1" ).accordion({ active: $( "#list1 h3:last" ) });
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "activate", $( "#list1 h3:first" ) );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "activate", $( "#list1 h3" )[ 1 ] );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ active: Selector }", function() {
@@ -72,9 +76,9 @@ test( "{ active: Selector }", function() {
var element = $("#list1").accordion({
active: "h3:last"
});
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", "h3:eq(1)" );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ active: Element }", function() {
@@ -82,9 +86,9 @@ test( "{ active: Element }", function() {
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )[ 0 ]
});
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", $( "#list1 h3:eq(1)" )[ 0 ] );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ active: jQuery Object }", function() {
@@ -92,20 +96,20 @@ test( "{ active: jQuery Object }", function() {
var element = $( "#list1" ).accordion({
active: $( "#list1 h3:last" )
});
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", $( "#list1 h3:eq(1)" ) );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
-module( "accordion (deprecated) - height options", accordion_setupTeardown() );
+module( "accordion (deprecated) - height options", setupTeardown() );
test( "{ autoHeight: true }, default", function() {
expect( 3 );
- accordion_equalHeights( $( "#navigation" ).accordion({ autoHeight: true }), 95, 130 );
+ equalHeights( $( "#navigation" ).accordion({ autoHeight: true }), 95, 130 );
});
test( "{ autoHeight: false }", function() {
@@ -124,7 +128,7 @@ test( "{ fillSpace: true }", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- accordion_equalHeights( element, 446, 458 );
+ equalHeights( element, 446, 458 );
});
test( "{ fillSapce: true } with sibling", function() {
@@ -138,7 +142,7 @@ test( "{ fillSapce: true } with sibling", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- accordion_equalHeights( element , 346, 358);
+ equalHeights( element , 346, 358);
});
test( "{ fillSpace: true } with multiple siblings", function() {
@@ -167,14 +171,14 @@ test( "{ fillSpace: true } with multiple siblings", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ fillSpace: true });
- accordion_equalHeights( element, 296, 308 );
+ equalHeights( element, 296, 308 );
});
-module( "accordion (deprecated) - icons", accordion_setupTeardown() );
+module( "accordion (deprecated) - icons", setupTeardown() );
test( "icons, headerSelected", function() {
expect( 3 );
@@ -191,7 +195,7 @@ test( "icons, headerSelected", function() {
-module( "accordion (deprecated) - resize", accordion_setupTeardown() );
+module( "accordion (deprecated) - resize", setupTeardown() );
test( "resize", function() {
expect( 6 );
@@ -202,18 +206,18 @@ test( "resize", function() {
.accordion({
heightStyle: "fill"
});
- accordion_equalHeights( element, 246, 258 );
+ equalHeights( element, 246, 258 );
element.parent().height( 500 );
element.accordion( "resize" );
- accordion_equalHeights( element, 446, 458 );
+ equalHeights( element, 446, 458 );
});
-module( "accordion (deprecated) - navigation", accordion_setupTeardown() );
+module( "accordion (deprecated) - navigation", setupTeardown() );
test( "{ navigation: true, navigationFilter: header }", function() {
expect( 2 );
@@ -224,7 +228,7 @@ test( "{ navigation: true, navigationFilter: header }", function() {
}
});
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "{ navigation: true, navigationFilter: content }", function() {
@@ -236,14 +240,14 @@ test( "{ navigation: true, navigationFilter: content }", function() {
}
});
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
-module( "accordion (deprecated) - changestart/change events", accordion_setupTeardown() );
+module( "accordion (deprecated) - changestart/change events", setupTeardown() );
test( "changestart", function() {
expect( 26 );
@@ -261,10 +265,10 @@ test( "changestart", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.accordion( "option", "active", 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.one( "accordionchangestart", function( event, ui ) {
equal( ui.oldHeader.size(), 1 );
@@ -275,10 +279,10 @@ test( "changestart", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
headers.eq( 1 ).click();
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.one( "accordionchangestart", function( event, ui ) {
equal( ui.oldHeader.size(), 1 );
@@ -287,10 +291,10 @@ test( "changestart", function() {
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
equal( ui.newHeader.size(), 0 );
equal( ui.newContent.size(), 0 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
element.accordion( "option", "active", false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "change", function() {
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index 7e3d1f8d0..932e4637d 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -1,6 +1,9 @@
(function( $ ) {
-module( "accordion: events", accordion_setupTeardown() );
+var setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion: events", setupTeardown() );
test( "create", function() {
expect( 10 );
@@ -58,10 +61,10 @@ test( "beforeActivate", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 0 ] );
equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 0 ] );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.accordion( "option", "active", 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
equal( event.originalEvent.type, "click" );
@@ -73,10 +76,10 @@ test( "beforeActivate", function() {
strictEqual( ui.newHeader[ 0 ], headers[ 1 ] );
equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 1 ] );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
headers.eq( 1 ).click();
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
@@ -86,10 +89,10 @@ test( "beforeActivate", function() {
strictEqual( ui.oldContent[ 0 ], content[ 1 ] );
equal( ui.newHeader.size(), 0 );
equal( ui.newContent.size(), 0 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
element.accordion( "option", "active", false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
element.one( "accordionbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ) );
@@ -100,10 +103,10 @@ test( "beforeActivate", function() {
equal( ui.newContent.size(), 1 );
strictEqual( ui.newContent[ 0 ], content[ 2 ] );
event.preventDefault();
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
element.accordion( "option", "active", 2 );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "activate", function() {
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index 2f4722070..2c5b36632 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -1,6 +1,10 @@
(function( $ ) {
-module( "accordion: methods", accordion_setupTeardown() );
+var equalHeights = TestHelpers.accordion.equalHeights,
+ setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion: methods", setupTeardown() );
test( "destroy", function() {
expect( 1 );
@@ -12,17 +16,17 @@ test( "destroy", function() {
test( "enable/disable", function() {
expect( 4 );
var element = $( "#list1" ).accordion();
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "disable" );
// event does nothing
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
// option still works
element.accordion( "option", "active", 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "enable" );
element.accordion( "option", "active", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "refresh", function() {
@@ -34,11 +38,11 @@ test( "refresh", function() {
.accordion({
heightStyle: "fill"
});
- accordion_equalHeights( element, 246, 258 );
+ equalHeights( element, 246, 258 );
element.parent().height( 500 );
element.accordion( "refresh" );
- accordion_equalHeights( element, 446, 458 );
+ equalHeights( element, 446, 458 );
});
}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index a29c7f07d..f64ddc675 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -1,12 +1,16 @@
(function( $ ) {
-module( "accordion: options", accordion_setupTeardown() );
+var equalHeights = TestHelpers.accordion.equalHeights,
+ setupTeardown = TestHelpers.accordion.setupTeardown,
+ state = TestHelpers.accordion.state;
+
+module( "accordion: options", setupTeardown() );
test( "{ active: default }", function() {
expect( 2 );
var element = $( "#list1" ).accordion();
equal( element.accordion( "option", "active" ), 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
test( "{ active: false }", function() {
@@ -15,19 +19,19 @@ test( "{ active: false }", function() {
active: false,
collapsible: true
});
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
equal( element.find( ".ui-accordion-header.ui-state-active" ).size(), 0, "no headers selected" );
equal( element.accordion( "option", "active" ), false );
element.accordion( "option", "collapsible", false );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
equal( element.accordion( "option", "active" ), 0 );
element.accordion( "destroy" );
element.accordion({
active: false
});
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
strictEqual( element.accordion( "option", "active" ), 0 );
});
@@ -37,19 +41,19 @@ test( "{ active: Number }", function() {
active: 2
});
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", 0 );
equal( element.accordion( "option", "active" ), 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).click();
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "option", "active", 10 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
if ( $.uiBackCompat === false ) {
@@ -59,19 +63,19 @@ if ( $.uiBackCompat === false ) {
active: -1
});
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "active", -2 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "option", "active", -10 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.accordion( "option", "active", -3 );
equal( element.accordion( "option", "active" ), 0 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
});
}
@@ -252,11 +256,11 @@ test( "{ collapsible: false }", function() {
});
element.accordion( "option", "active", false );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).click();
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ collapsible: true }", function() {
@@ -268,15 +272,15 @@ test( "{ collapsible: true }", function() {
element.accordion( "option", "active", false );
equal( element.accordion( "option", "active" ), false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
element.accordion( "option", "active", 1 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).click();
equal( element.accordion( "option", "active" ), false );
- accordion_state( element, 0, 0, 0 );
+ state( element, 0, 0, 0 );
});
test( "{ event: null }", function() {
@@ -284,16 +288,16 @@ test( "{ event: null }", function() {
var element = $( "#list1" ).accordion({
event: null
});
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "option", "active", 1 );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).click();
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ event: custom }", function() {
@@ -301,20 +305,20 @@ test( "{ event: custom }", function() {
var element = $( "#list1" ).accordion({
event: "custom1 custom2"
});
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
// ensure default click handler isn't bound
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "click" );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
element.find( ".ui-accordion-header" ).eq( 2 ).trigger( "custom2" );
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.accordion( "option", "event", "custom3" );
@@ -322,20 +326,20 @@ test( "{ event: custom }", function() {
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom1" );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom2" );
equal( element.accordion( "option", "active" ), 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "custom3" );
equal( element.accordion( "option", "active" ), 1 );
- accordion_state( element, 0, 1, 0 );
+ state( element, 0, 1, 0 );
});
test( "{ header: default }", function() {
expect( 2 );
// default: > li > :first-child,> :not(li):even
// > :not(li):even
- accordion_state( $( "#list1" ).accordion(), 1, 0, 0);
+ state( $( "#list1" ).accordion(), 1, 0, 0);
// > li > :first-child
- accordion_state( $( "#navigation" ).accordion(), 1, 0, 0);
+ state( $( "#navigation" ).accordion(), 1, 0, 0);
});
test( "{ header: custom }", function() {
@@ -347,15 +351,15 @@ test( "{ header: custom }", function() {
ok( $( this ).hasClass( "ui-accordion-header" ) );
});
equal( element.find( ".ui-accordion-header" ).length, 3 );
- accordion_state( element, 1, 0, 0 );
+ state( element, 1, 0, 0 );
element.accordion( "option", "active", 2 );
- accordion_state( element, 0, 0, 1 );
+ state( element, 0, 0, 1 );
});
test( "{ heightStyle: 'auto' }", function() {
expect( 3 );
var element = $( "#navigation" ).accordion({ heightStyle: "auto" });
- accordion_equalHeights( element, 95, 130 );
+ equalHeights( element, 95, 130 );
});
test( "{ heightStyle: 'content' }", function() {
@@ -373,7 +377,7 @@ test( "{ heightStyle: 'fill' }", function() {
expect( 3 );
$( "#navigationWrapper" ).height( 500 );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- accordion_equalHeights( element, 446, 458 );
+ equalHeights( element, 446, 458 );
});
test( "{ heightStyle: 'fill' } with sibling", function() {
@@ -387,7 +391,7 @@ test( "{ heightStyle: 'fill' } with sibling", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- accordion_equalHeights( element , 346, 358);
+ equalHeights( element , 346, 358);
});
test( "{ heightStyle: 'fill' } with multiple siblings", function() {
@@ -416,7 +420,7 @@ test( "{ heightStyle: 'fill' } with multiple siblings", function() {
})
.prependTo( "#navigationWrapper" );
var element = $( "#navigation" ).accordion({ heightStyle: "fill" });
- accordion_equalHeights( element, 296, 308 );
+ equalHeights( element, 296, 308 );
});
test( "{ icons: false }", function() {
diff --git a/tests/unit/accordion/accordion_test_helpers.js b/tests/unit/accordion/accordion_test_helpers.js
index 889608fba..56967793d 100644
--- a/tests/unit/accordion/accordion_test_helpers.js
+++ b/tests/unit/accordion/accordion_test_helpers.js
@@ -1,30 +1,32 @@
-function accordion_state( accordion ) {
- var expected = $.makeArray( arguments ).slice( 1 ),
- actual = accordion.find( ".ui-accordion-content" ).map(function() {
- return $( this ).css( "display" ) === "none" ? 0 : 1;
- }).get();
- QUnit.push( QUnit.equiv(actual, expected), actual, expected );
-}
+TestHelpers.accordion = {
+ equalHeights: function( accordion, min, max ) {
+ var sizes = [];
+ accordion.find( ".ui-accordion-content" ).each(function() {
+ sizes.push( $( this ).outerHeight() );
+ });
+ ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
+ "must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
+ deepEqual( sizes[ 0 ], sizes[ 1 ] );
+ deepEqual( sizes[ 0 ], sizes[ 2 ] );
+ },
-function accordion_equalHeights( accordion, min, max ) {
- var sizes = [];
- accordion.find( ".ui-accordion-content" ).each(function() {
- sizes.push( $( this ).outerHeight() );
- });
- ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
- "must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
- deepEqual( sizes[ 0 ], sizes[ 1 ] );
- deepEqual( sizes[ 0 ], sizes[ 2 ] );
-}
+ setupTeardown: function() {
+ var animate = $.ui.accordion.prototype.options.animate;
+ return {
+ setup: function() {
+ $.ui.accordion.prototype.options.animate = false;
+ },
+ teardown: function() {
+ $.ui.accordion.prototype.options.animate = animate;
+ }
+ };
+ },
-function accordion_setupTeardown() {
- var animate = $.ui.accordion.prototype.options.animate;
- return {
- setup: function() {
- $.ui.accordion.prototype.options.animate = false;
- },
- teardown: function() {
- $.ui.accordion.prototype.options.animate = animate;
- }
- };
-}
+ state: function( accordion ) {
+ var expected = $.makeArray( arguments ).slice( 1 ),
+ actual = accordion.find( ".ui-accordion-content" ).map(function() {
+ return $( this ).css( "display" ) === "none" ? 0 : 1;
+ }).get();
+ QUnit.push( QUnit.equiv(actual, expected), actual, expected );
+ }
+};
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index 2ef6bf472..648b302ee 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -1,5 +1,7 @@
(function() {
+window.TestHelpers = {};
+
function testWidgetDefaults( widget, defaults ) {
var pluginDefaults = $.ui[ widget ].prototype.options;