Accordion: Convert tests to new infrastructure

Ref #10119
Ref gh-1528
This commit is contained in:
Scott González 2015-04-03 15:24:09 -04:00
parent 2e1c72fb59
commit e39ee9d669
7 changed files with 54 additions and 49 deletions

View File

@ -4,31 +4,8 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>jQuery UI Accordion Test Suite</title> <title>jQuery UI Accordion Test Suite</title>
<script src="../../jquery.js"></script> <script src="../../lib/css.js" data-modules="core accordion"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"> <script src="../../lib/bootstrap.js" data-widget="accordion"></script>
<script src="../../../external/qunit/qunit.js"></script>
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="../../../external/qunit-assert-classes/qunit-assert-classes.js"></script>
<script>
TestHelpers.loadResources({
css: [ "core", "accordion" ],
js: [
"ui/core.js",
"ui/widget.js",
"ui/accordion.js"
]
});
</script>
<script src="accordion_test_helpers.js"></script>
<script src="accordion_common.js"></script>
<script src="accordion_core.js"></script>
<script src="accordion_events.js"></script>
<script src="accordion_methods.js"></script>
<script src="accordion_options.js"></script>
<script src="../swarminject.js"></script>
<style> <style>
#list, #list1 *, #navigation, #navigation * { #list, #list1 *, #navigation, #navigation * {
margin: 0; margin: 0;

View File

@ -1,4 +1,9 @@
TestHelpers.commonWidgetTests( "accordion", { define( [
"lib/common",
"ui/accordion"
], function( common ) {
common.testWidget( "accordion", {
defaults: { defaults: {
active: 0, active: 0,
animate: {}, animate: {},
@ -23,3 +28,5 @@ TestHelpers.commonWidgetTests( "accordion", {
create: null create: null
} }
}); });
} );

View File

@ -1,7 +1,11 @@
(function( $ ) { define( [
"jquery",
"./accordion_test_helpers",
"ui/accordion"
], function( $, accordionTestHelper ) {
var setupTeardown = TestHelpers.accordion.setupTeardown, var setupTeardown = accordionTestHelper.setupTeardown,
state = TestHelpers.accordion.state; state = accordionTestHelper.state;
module( "accordion: core", setupTeardown() ); module( "accordion: core", setupTeardown() );
@ -200,4 +204,4 @@ asyncTest( "keyboard support", function( assert ) {
} }
}); });
}( jQuery ) ); } );

View File

@ -1,7 +1,11 @@
(function( $ ) { define( [
"jquery",
"./accordion_test_helpers",
"ui/accordion"
], function( $, accordionTestHelper ) {
var setupTeardown = TestHelpers.accordion.setupTeardown, var setupTeardown = accordionTestHelper.setupTeardown,
state = TestHelpers.accordion.state; state = accordionTestHelper.state;
module( "accordion: events", setupTeardown() ); module( "accordion: events", setupTeardown() );
@ -161,4 +165,4 @@ test( "activate", function() {
element.accordion( "option", "active", 1 ); element.accordion( "option", "active", 1 );
}); });
}( jQuery ) ); } );

View File

@ -1,14 +1,18 @@
(function( $ ) { define( [
"jquery",
"./accordion_test_helpers",
"ui/accordion"
], function( $, accordionTestHelper ) {
var equalHeight = TestHelpers.accordion.equalHeight, var equalHeight = accordionTestHelper.equalHeight,
setupTeardown = TestHelpers.accordion.setupTeardown, setupTeardown = accordionTestHelper.setupTeardown,
state = TestHelpers.accordion.state; state = accordionTestHelper.state;
module( "accordion: methods", setupTeardown() ); module( "accordion: methods", setupTeardown() );
test( "destroy", function() { test( "destroy", function( assert ) {
expect( 1 ); expect( 1 );
domEqual( "#list1", function() { assert.domEqual( "#list1", function() {
$( "#list1" ).accordion().accordion( "destroy" ); $( "#list1" ).accordion().accordion( "destroy" );
}); });
}); });
@ -129,4 +133,4 @@ test( "widget", function() {
strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" ); strictEqual( widgetElement[ 0 ], element[ 0 ], "same element" );
}); });
}( jQuery ) ); } );

View File

@ -1,8 +1,12 @@
(function( $ ) { define( [
"jquery",
"./accordion_test_helpers",
"ui/accordion"
], function( $, accordionTestHelper ) {
var equalHeight = TestHelpers.accordion.equalHeight, var equalHeight = accordionTestHelper.equalHeight,
setupTeardown = TestHelpers.accordion.setupTeardown, setupTeardown = accordionTestHelper.setupTeardown,
state = TestHelpers.accordion.state; state = accordionTestHelper.state;
module( "accordion: options", setupTeardown() ); module( "accordion: options", setupTeardown() );
@ -460,4 +464,4 @@ test( "{ icons: hash }", function( assert ) {
assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a2" ); assert.hasClasses( element.find( ".ui-accordion-header.ui-state-active span.ui-icon" ), "a2" );
}); });
}( jQuery ) ); } );

View File

@ -1,4 +1,6 @@
TestHelpers.accordion = { define( function() {
return {
equalHeight: function( accordion, height ) { equalHeight: function( accordion, height ) {
accordion.find( ".ui-accordion-content" ).each(function() { accordion.find( ".ui-accordion-content" ).each(function() {
equal( $( this ).outerHeight(), height ); equal( $( this ).outerHeight(), height );
@ -20,8 +22,11 @@ TestHelpers.accordion = {
state: function( accordion ) { state: function( accordion ) {
var expected = $.makeArray( arguments ).slice( 1 ), var expected = $.makeArray( arguments ).slice( 1 ),
actual = accordion.find( ".ui-accordion-content" ).map(function() { actual = accordion.find( ".ui-accordion-content" ).map(function() {
return $( this ).css( "display" ) === "none" ? 0 : 1; return $( this ).css( "display" ) === "none" ? 0 : 1;
}).get(); }).get();
QUnit.push( QUnit.equiv(actual, expected), actual, expected ); QUnit.push( QUnit.equiv(actual, expected), actual, expected );
} }
}; };
} );