aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-24 15:45:29 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-24 15:45:29 -0500
commit140d90a9a4d0c77658ff8a811aebe899dcf11f2b (patch)
treef0417e6dd9bf8a78256d1766c6b9ac840a5f1b7f
parent3ce23223ae5ad1f15c0986c313df02bc5dcc264e (diff)
downloadjquery-ui-140d90a9a4d0c77658ff8a811aebe899dcf11f2b.tar.gz
jquery-ui-140d90a9a4d0c77658ff8a811aebe899dcf11f2b.zip
Accordion: Test cleanup.
-rw-r--r--tests/unit/accordion/accordion_core.js59
-rw-r--r--tests/unit/accordion/accordion_defaults.js7
-rw-r--r--tests/unit/accordion/accordion_events.js54
-rw-r--r--tests/unit/accordion/deprecated/accordion.html (renamed from tests/unit/accordion/accordion_deprecated.html)30
-rw-r--r--tests/unit/accordion/deprecated/accordion_defaults_deprecated.js (renamed from tests/unit/accordion/accordion_defaults_deprecated.js)5
-rw-r--r--tests/unit/accordion/deprecated/accordion_deprecated.js (renamed from tests/unit/accordion/accordion_deprecated.js)0
-rw-r--r--ui/jquery.ui.accordion.js4
7 files changed, 75 insertions, 84 deletions
diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js
index 40a711abf..fa0facc80 100644
--- a/tests/unit/accordion/accordion_core.js
+++ b/tests/unit/accordion/accordion_core.js
@@ -1,40 +1,35 @@
-/*
- * accordion_core.js
- */
+(function( $ ) {
+module( "accordion: core" );
-(function($) {
-
-module("accordion: core");
-
-test("handle click on header-descendant", function() {
- var ac = $('#navigation').accordion({ autoHeight: false });
- $('#navigation h2:eq(1) a').trigger("click");
- state(ac, 0, 1, 0);
+test( "handle click on header-descendant", function() {
+ var ac = $( "#navigation" ).accordion();
+ $( "#navigation h2:eq(1) a" ).click();
+ state( ac, 0, 1, 0 );
});
-test("ui-accordion-heading class added to headers anchor", function() {
- expect(1);
- var ac = $("#list1").accordion();
- var anchors = $(".ui-accordion-heading");
- equals( anchors.length, "3");
+test( "ui-accordion-heading class added to headers anchor", function() {
+ expect( 1 );
+ var ac = $( "#list1" ).accordion();
+ var anchors = $( ".ui-accordion-heading" );
+ equals( anchors.length, 3 );
});
-test("accessibility", function () {
- expect(9);
- var ac = $('#list1').accordion().accordion("option", "active", 1);
- var headers = $(".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( 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");
- ac.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");
+test( "accessibility", function () {
+ expect( 9 );
+ var ac = $( "#list1" ).accordion().accordion( "option", "active", 1 );
+ var headers = $( ".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( 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" );
+ ac.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" );
});
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_defaults.js b/tests/unit/accordion/accordion_defaults.js
index 78630adc7..c2904d39a 100644
--- a/tests/unit/accordion/accordion_defaults.js
+++ b/tests/unit/accordion/accordion_defaults.js
@@ -1,6 +1,3 @@
-/*
- * accordion_defaults.js
- */
var accordion_defaults = {
active: 0,
@@ -11,8 +8,8 @@ var accordion_defaults = {
header: "> li > :first-child,> :not(li):even",
heightStyle: "auto",
icons: {
- "header": "ui-icon-triangle-1-e",
- "activeHeader": "ui-icon-triangle-1-s"
+ "activeHeader": "ui-icon-triangle-1-s",
+ "header": "ui-icon-triangle-1-e"
}
};
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index 4798f7404..ff9590eac 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -1,30 +1,32 @@
-/*
- * accordion_events.js
- */
-(function($) {
+(function( $ ) {
-module("accordion: events");
+module( "accordion: events" );
-test("accordionchange event, open closed and close again", function() {
- expect(8);
- $("#list1").accordion({
- active: false,
- collapsible: true
- })
- .one("accordionchange", function(event, ui) {
- equals( ui.oldHeader.size(), 0 );
- equals( ui.oldContent.size(), 0 );
- equals( ui.newHeader.size(), 1 );
- equals( ui.newContent.size(), 1 );
- })
- .accordion("option", "active", 0)
- .one("accordionchange", function(event, ui) {
- equals( ui.oldHeader.size(), 1 );
- equals( ui.oldContent.size(), 1 );
- equals( ui.newHeader.size(), 0 );
- equals( ui.newContent.size(), 0 );
- })
- .accordion("option", "active", false);
+// TODO: verify correct elements in ui properties
+// TODO: add tests for switching between active panels (not collapsed)
+// TODO: add tests for changestart
+// TODO: move change/changestart to deprecated tests (add activate/beforeactivate)
+test( "accordionchange event, open closed and close again", function() {
+ expect( 8 );
+ $( "#list1" )
+ .accordion({
+ active: false,
+ collapsible: true
+ })
+ .one( "accordionchange", function( event, ui ) {
+ equals( ui.oldHeader.size(), 0 );
+ equals( ui.oldContent.size(), 0 );
+ equals( ui.newHeader.size(), 1 );
+ equals( ui.newContent.size(), 1 );
+ })
+ .accordion( "option", "active", 0 )
+ .one( "accordionchange", function( event, ui ) {
+ equals( ui.oldHeader.size(), 1 );
+ equals( ui.oldContent.size(), 1 );
+ equals( ui.newHeader.size(), 0 );
+ equals( ui.newContent.size(), 0 );
+ })
+ .accordion( "option", "active", false );
});
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/deprecated/accordion.html
index c104df4d5..d5e55f2e4 100644
--- a/tests/unit/accordion/accordion_deprecated.html
+++ b/tests/unit/accordion/deprecated/accordion.html
@@ -4,17 +4,17 @@
<meta charset="utf-8">
<title>jQuery UI Accordion Test Suite</title>
- <link rel="stylesheet" href="../../../themes/base/jquery.ui.accordion.css">
+ <link rel="stylesheet" href="../../../../themes/base/jquery.ui.accordion.css">
- <script src="../../../jquery-1.4.4.js"></script>
- <script src="../../../ui/jquery.ui.core.js"></script>
- <script src="../../../ui/jquery.ui.widget.js"></script>
- <script src="../../../ui/jquery.ui.accordion.js"></script>
+ <script src="../../../../jquery-1.4.4.js"></script>
+ <script src="../../../../ui/jquery.ui.core.js"></script>
+ <script src="../../../../ui/jquery.ui.widget.js"></script>
+ <script src="../../../../ui/jquery.ui.accordion.js"></script>
- <link rel="stylesheet" href="../../../external/qunit.css">
- <script src="../../../external/qunit.js"></script>
- <script src="../../jquery.simulate.js"></script>
- <script src="../testsuite.js"></script>
+ <link rel="stylesheet" href="../../../../external/qunit.css">
+ <script src="../../../../external/qunit.js"></script>
+ <script src="../../../jquery.simulate.js"></script>
+ <script src="../../testsuite.js"></script>
<script>
$.ui.accordion.prototype.options.animated = false;
@@ -39,15 +39,15 @@
same(sizes[0], sizes[2]);
}
</script>
- <script src="accordion_core.js"></script>
+ <script src="../accordion_core.js"></script>
<script src="accordion_defaults_deprecated.js"></script>
- <script src="accordion_events.js"></script>
- <script src="accordion_methods.js"></script>
- <script src="accordion_options.js"></script>
- <script src="accordion_tickets.js"></script>
+ <script src="../accordion_events.js"></script>
+ <script src="../accordion_methods.js"></script>
+ <script src="../accordion_options.js"></script>
+ <script src="../accordion_tickets.js"></script>
<script src="accordion_deprecated.js"></script>
- <script src="../swarminject.js"></script>
+ <script src="../../swarminject.js"></script>
<style>
#main { font-size: 10pt; font-family: "trebuchet ms", verdana, arial; }
#list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; }
diff --git a/tests/unit/accordion/accordion_defaults_deprecated.js b/tests/unit/accordion/deprecated/accordion_defaults_deprecated.js
index 41998ea7a..386354e83 100644
--- a/tests/unit/accordion/accordion_defaults_deprecated.js
+++ b/tests/unit/accordion/deprecated/accordion_defaults_deprecated.js
@@ -1,6 +1,3 @@
-/*
- * accordion_defaults.js
- */
var accordion_defaults = {
active: 0,
@@ -14,8 +11,8 @@ var accordion_defaults = {
header: "> li > :first-child,> :not(li):even",
heightStyle: null,
icons: {
- "header": "ui-icon-triangle-1-e",
"activeHeader": null,
+ "header": "ui-icon-triangle-1-e",
"headerSelected": "ui-icon-triangle-1-s"
},
navigation: false,
diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/deprecated/accordion_deprecated.js
index b219cf8c3..b219cf8c3 100644
--- a/tests/unit/accordion/accordion_deprecated.js
+++ b/tests/unit/accordion/deprecated/accordion_deprecated.js
diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js
index a06cd2a2a..d855da5f3 100644
--- a/ui/jquery.ui.accordion.js
+++ b/ui/jquery.ui.accordion.js
@@ -22,8 +22,8 @@ $.widget( "ui.accordion", {
header: "> li > :first-child,> :not(li):even",
heightStyle: "auto",
icons: {
- header: "ui-icon-triangle-1-e",
- activeHeader: "ui-icon-triangle-1-s"
+ activeHeader: "ui-icon-triangle-1-s",
+ header: "ui-icon-triangle-1-e"
}
},