aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2011-01-24 19:20:09 -0500
committerScott González <scott.gonzalez@gmail.com>2011-01-24 19:20:09 -0500
commit5ed1046a4ac271a1f20cc1f19aa50bec15cd9704 (patch)
tree029e568f6d417e884a8e9e2db6a346b1430a461c /tests
parentecc0ef53dee0eb3ce432348762abf4550aad8b36 (diff)
downloadjquery-ui-5ed1046a4ac271a1f20cc1f19aa50bec15cd9704.tar.gz
jquery-ui-5ed1046a4ac271a1f20cc1f19aa50bec15cd9704.zip
Accordion tests: Cleanup.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/accordion/accordio.html43
-rw-r--r--tests/unit/accordion/accordion.html43
-rw-r--r--tests/unit/accordion/accordion_core.js2
-rw-r--r--tests/unit/accordion/accordion_defaults.js29
-rw-r--r--tests/unit/accordion/accordion_defaults_deprecated.js43
-rw-r--r--tests/unit/accordion/accordion_deprecated.js52
-rw-r--r--tests/unit/accordion/accordion_events.js2
-rw-r--r--tests/unit/accordion/accordion_methods.js105
-rw-r--r--tests/unit/accordion/accordion_options.js228
-rw-r--r--tests/unit/accordion/accordion_tickets.js9
-rw-r--r--tests/unit/testsuite.js74
11 files changed, 369 insertions, 261 deletions
diff --git a/tests/unit/accordion/accordio.html b/tests/unit/accordion/accordio.html
index c104df4d5..db202fe43 100644
--- a/tests/unit/accordion/accordio.html
+++ b/tests/unit/accordion/accordio.html
@@ -17,30 +17,37 @@
<script src="../testsuite.js"></script>
<script>
- $.ui.accordion.prototype.options.animated = false;
-
- function state(accordion) {
- var args = $.makeArray(arguments).slice(1);
- var result = [];
- $.each(args, function(i, n) {
- result.push( accordion.find(".ui-accordion-content").eq(i).filter(function() {
- return $(this).css("display") != "none"
- }).length ? 1 : 0 );
- });
- same(args, result)
+ function state( accordion ) {
+ var expected = $.makeArray( arguments ).slice( 1 );
+ var actual = accordion.find( ".ui-accordion-content" ).map(function() {
+ return $( this ).css( "display" ) === "none" ? 0 : 1;
+ }).get();
+ same( actual, expected );
}
- function equalHeights(accordion, min, max) {
+ function equalHeights( accordion, min, max ) {
var sizes = [];
- accordion.find(".ui-accordion-content").each(function() {
- sizes.push($(this).outerHeight());
+ 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] );
- same(sizes[0], sizes[1]);
- same(sizes[0], sizes[2]);
+ ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
+ "must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
+ same( sizes[ 0 ], sizes[ 1 ] );
+ same( sizes[ 0 ], sizes[ 2 ] );
+ }
+ function accordionSetupTeardown() {
+ var animated = $.ui.accordion.prototype.options.animated;
+ return {
+ setup: function() {
+ $.ui.accordion.prototype.options.animated = false;
+ },
+ teardown: function() {
+ $.ui.accordion.prototype.options.animated = animated;
+ }
+ };
}
</script>
- <script src="accordion_core.js"></script>
<script src="accordion_defaults_deprecated.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>
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html
index 88226be31..23380000e 100644
--- a/tests/unit/accordion/accordion.html
+++ b/tests/unit/accordion/accordion.html
@@ -20,30 +20,37 @@
<script src="../testsuite.js"></script>
<script>
- $.ui.accordion.prototype.options.animated = false;
-
- function state(accordion) {
- var args = $.makeArray(arguments).slice(1);
- var result = [];
- $.each(args, function(i, n) {
- result.push( accordion.find(".ui-accordion-content").eq(i).filter(function() {
- return $(this).css("display") != "none"
- }).length ? 1 : 0 );
- });
- same(args, result)
+ function state( accordion ) {
+ var expected = $.makeArray( arguments ).slice( 1 );
+ var actual = accordion.find( ".ui-accordion-content" ).map(function() {
+ return $( this ).css( "display" ) === "none" ? 0 : 1;
+ }).get();
+ same( actual, expected );
}
- function equalHeights(accordion, min, max) {
+ function equalHeights( accordion, min, max ) {
var sizes = [];
- accordion.find(".ui-accordion-content").each(function() {
- sizes.push($(this).outerHeight());
+ 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] );
- same(sizes[0], sizes[1]);
- same(sizes[0], sizes[2]);
+ ok( sizes[ 0 ] >= min && sizes[ 0 ] <= max,
+ "must be within " + min + " and " + max + ", was " + sizes[ 0 ] );
+ same( sizes[ 0 ], sizes[ 1 ] );
+ same( sizes[ 0 ], sizes[ 2 ] );
+ }
+ function accordionSetupTeardown() {
+ var animated = $.ui.accordion.prototype.options.animated;
+ return {
+ setup: function() {
+ $.ui.accordion.prototype.options.animated = false;
+ },
+ teardown: function() {
+ $.ui.accordion.prototype.options.animated = animated;
+ }
+ };
}
</script>
- <script src="accordion_core.js"></script>
<script src="accordion_defaults.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>
diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js
index fa0facc80..601d2ed44 100644
--- a/tests/unit/accordion/accordion_core.js
+++ b/tests/unit/accordion/accordion_core.js
@@ -1,6 +1,6 @@
(function( $ ) {
-module( "accordion: core" );
+module( "accordion: core", accordionSetupTeardown() );
test( "handle click on header-descendant", function() {
var ac = $( "#navigation" ).accordion();
diff --git a/tests/unit/accordion/accordion_defaults.js b/tests/unit/accordion/accordion_defaults.js
index c2904d39a..95a478057 100644
--- a/tests/unit/accordion/accordion_defaults.js
+++ b/tests/unit/accordion/accordion_defaults.js
@@ -1,16 +1,15 @@
-
-var accordion_defaults = {
- active: 0,
- animated: false,
- collapsible: false,
- disabled: false,
- event: "click",
- header: "> li > :first-child,> :not(li):even",
- heightStyle: "auto",
- icons: {
- "activeHeader": "ui-icon-triangle-1-s",
- "header": "ui-icon-triangle-1-e"
+commonWidgetTests( "accordion", {
+ defaults: {
+ active: 0,
+ animated: "slide",
+ collapsible: false,
+ disabled: false,
+ event: "click",
+ header: "> li > :first-child,> :not(li):even",
+ heightStyle: "auto",
+ icons: {
+ "activeHeader": "ui-icon-triangle-1-s",
+ "header": "ui-icon-triangle-1-e"
+ }
}
-};
-
-commonWidgetTests( "accordion", { defaults: accordion_defaults } );
+});
diff --git a/tests/unit/accordion/accordion_defaults_deprecated.js b/tests/unit/accordion/accordion_defaults_deprecated.js
index 386354e83..b90b472e2 100644
--- a/tests/unit/accordion/accordion_defaults_deprecated.js
+++ b/tests/unit/accordion/accordion_defaults_deprecated.js
@@ -1,22 +1,21 @@
-
-var accordion_defaults = {
- active: 0,
- animated: false,
- autoHeight: true,
- clearStyle: false,
- collapsible: false,
- disabled: false,
- event: "click",
- fillSpace: false,
- header: "> li > :first-child,> :not(li):even",
- heightStyle: null,
- icons: {
- "activeHeader": null,
- "header": "ui-icon-triangle-1-e",
- "headerSelected": "ui-icon-triangle-1-s"
- },
- navigation: false,
- navigationFilter: function() {}
-};
-
-commonWidgetTests( "accordion", { defaults: accordion_defaults } );
+commonWidgetTests( "accordion", {
+ defaults: {
+ active: 0,
+ animated: "slide",
+ autoHeight: true,
+ clearStyle: false,
+ collapsible: false,
+ disabled: false,
+ event: "click",
+ fillSpace: false,
+ header: "> li > :first-child,> :not(li):even",
+ heightStyle: null,
+ icons: {
+ "activeHeader": null,
+ "header": "ui-icon-triangle-1-e",
+ "headerSelected": "ui-icon-triangle-1-s"
+ },
+ navigation: false,
+ navigationFilter: function() {}
+ }
+});
diff --git a/tests/unit/accordion/accordion_deprecated.js b/tests/unit/accordion/accordion_deprecated.js
index b219cf8c3..2fa3ca41a 100644
--- a/tests/unit/accordion/accordion_deprecated.js
+++ b/tests/unit/accordion/accordion_deprecated.js
@@ -5,7 +5,7 @@
(function($) {
-module("accordion (deprecated): expanded active option, activate method");
+module("accordion (deprecated): expanded active option, activate method", accordionSetupTeardown() );
test("activate", function() {
var expected = $('#list1').accordion(),
@@ -96,7 +96,7 @@ test("{ active: jQuery Object }", function() {
-module("accordion (deprecated) - height options");
+module("accordion (deprecated) - height options", accordionSetupTeardown() );
test("{ autoHeight: true }, default", function() {
equalHeights($('#navigation').accordion({ autoHeight: true }), 95, 130);
@@ -141,7 +141,7 @@ test("{ fillSpace: true } with multiple siblings", function() {
-module("accordion (deprecated) - icons");
+module("accordion (deprecated) - icons", accordionSetupTeardown() );
test("change headerSelected option after creation", function() {
var list = $("#list1");
@@ -151,4 +151,50 @@ test("change headerSelected option after creation", function() {
equals( $( "#list1 span.deprecated" ).length, 1);
});
+
+
+
+
+module( "accordion (deprecated) - resize", accordionSetupTeardown() );
+
+test( "resize", function() {
+ var expected = $( "#navigation" )
+ .parent()
+ .height( 300 )
+ .end()
+ .accordion({
+ heightStyle: "fill"
+ });
+ equalHeights( expected, 246, 258 );
+
+ expected.parent().height( 500 );
+ expected.accordion( "resize" );
+ equalHeights( expected, 446, 458 );
+});
+
+
+
+
+module( "accordion (deprecated) - navigation", accordionSetupTeardown() );
+
+test("{ navigation: true, navigationFilter: header }", function() {
+ $("#navigation").accordion({
+ navigation: true,
+ navigationFilter: function() {
+ return /\?p=1\.1\.3$/.test(this.href);
+ }
+ });
+ equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
+});
+
+test("{ navigation: true, navigationFilter: content }", function() {
+ $("#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" );
+});
+
})(jQuery);
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index ff9590eac..e0dbe82eb 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -1,6 +1,6 @@
(function( $ ) {
-module( "accordion: events" );
+module( "accordion: events", accordionSetupTeardown() );
// TODO: verify correct elements in ui properties
// TODO: add tests for switching between active panels (not collapsed)
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index c6754d277..e0ed734f6 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -1,71 +1,48 @@
-/*
- * accordion_methods.js
- */
-(function($) {
-
-module("accordion: methods");
-
-test("init", function() {
- $("<div></div>").appendTo('body').accordion().remove();
- ok(true, '.accordion() called on element');
-
- $([]).accordion().remove();
- ok(true, '.accordion() called on empty collection');
-
- $('<div></div>').accordion().remove();
- ok(true, '.accordion() called on disconnected DOMElement - never connected');
-
- $('<div></div>').appendTo('body').remove().accordion().remove();
- ok(true, '.accordion() called on disconnected DOMElement - removed');
-
- var el = $('<div></div>').accordion();
- var foo = el.accordion("option", "foo");
- el.remove();
- ok(true, 'arbitrary option getter after init');
-
- $('<div></div>').accordion().accordion("option", "foo", "bar").remove();
- ok(true, 'arbitrary option setter after init');
-});
-
-test("destroy", function() {
- var beforeHtml = $("#list1").find("div").css("font-style", "normal").end().parent().html();
- var afterHtml = $("#list1").accordion().accordion("destroy").parent().html();
- // Opera 9 outputs role="" instead of removing the attribute like everyone else
- if ($.browser.opera) {
- afterHtml = afterHtml.replace(/ role=""/g, "");
- }
+(function( $ ) {
+
+module( "accordion: methods", accordionSetupTeardown() );
+
+test( "destroy", function() {
+ var beforeHtml = $( "#list1" )
+ .find( "div" )
+ .css( "font-style", "normal" )
+ .end()
+ .parent()
+ .html();
+ var afterHtml = $( "#list1" )
+ .accordion()
+ .accordion( "destroy" )
+ .parent()
+ .html()
+ // Opera 9 outputs role="" instead of removing the attribute like everyone else
+ .replace( / role=""/g, "" );
equal( afterHtml, beforeHtml );
});
-test("enable", function() {
- var expected = $('#list1').accordion(),
- actual = expected.accordion('enable');
- equals(actual, expected, 'enable is chainable');
- state(expected, 1, 0, 0)
-});
-
-test("disable", function() {
- var expected = $('#list1').accordion(),
- actual = expected.accordion('disable');
- equals(actual, expected, 'disable is chainable');
-
- state(expected, 1, 0, 0)
- expected.accordion("option", "active", 1);
- state(expected, 1, 0, 0)
- expected.accordion("enable");
- expected.accordion("option", "active", 1);
- state(expected, 0, 1, 0)
+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 );
});
-test("refresh", function() {
- var expected = $('#navigation').parent().height(300).end().accordion({
- heightStyle: "fill"
- });
- equalHeights(expected, 246, 258);
-
- expected.parent().height(500);
- expected.accordion("refresh");
- equalHeights(expected, 446, 458);
+test( "refresh", function() {
+ var expected = $( "#navigation" )
+ .parent()
+ .height( 300 )
+ .end()
+ .accordion({
+ heightStyle: "fill"
+ });
+ equalHeights( expected, 246, 258 );
+
+ expected.parent().height( 500 );
+ expected.accordion( "refresh" );
+ equalHeights( expected, 446, 458 );
});
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index c7b4038ef..0e02f0372 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -1,128 +1,176 @@
-/*
- * accordion_options.js
- */
-(function($) {
+(function( $ ) {
-module("accordion: options");
+module( "accordion: options", accordionSetupTeardown() );
-test("{ active: first child }, default", function() {
- var ac = $("#list1").accordion();
- equals( ac.accordion('option', 'active'), 0);
- state(ac, 1, 0, 0)
+test( "{ active: default }", function() {
+ var ac = $( "#list1" ).accordion();
+ equals( ac.accordion( "option", "active" ), 0 );
+ state( ac, 1, 0, 0 );
});
-test("{ active: false }", function() {
- var ac = $("#list1").accordion({
+test( "{ active: false }", function() {
+ var ac = $( "#list1" ).accordion({
active: false,
collapsible: true
});
- state(ac, 0, 0, 0);
- equals( $("#list1 .ui-accordion-header.ui-state-active").size(), 0, "no headers selected" );
- equals( $("#list1").accordion('option', 'active'), false);
+ 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 );
+
+ // TODO: fix active: false when not collapsible
+// ac.accordion( "option", "collapsible", false );
+// state( ac, 1, 0, 0 );
+// equals( ac.accordion( "option", "active" ), 0 );
+//
+// ac.accordion( "destroy" );
+// ac.accordion({
+// active: false
+// });
+// state( ac, 1, 0, 0 );
+// strictEqual( ac.accordion( "option", "active" ), 0 );
});
-test("{ active: Number }", function() {
- expect(4);
- $("#list1").accordion({
- active: 0
+test( "{ active: Number }", function() {
+ var ac = $( "#list1" ).accordion({
+ active: 2
});
- equals( $("#list1").accordion('option', 'active'), 0);
+ equals( ac.accordion( "option", "active" ), 2 );
+ state( ac, 0, 0, 1 );
- $("#list1").accordion('option', 'active', 1);
- equals( $("#list1").accordion('option', 'active'), 1);
+ ac.accordion( "option", "active", 0 );
+ equals( ac.accordion( "option", "active" ), 0 );
+ state( ac, 1, 0, 0 );
- $('.ui-accordion-header:eq(2)', '#list1').click();
- equals( $("#list1").accordion('option', 'active'), 2);
+ ac.find( ".ui-accordion-header" ).eq( 1 ).click();
+ equals( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
- $("#list1").accordion('option', 'active', 0);
- equals( $("#list1").accordion('option', 'active'), 0);
+ ac.accordion( "option", "active", 10 );
+ equals( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
});
-test("{ heightStyle: 'auto' }, default", function() {
- equalHeights($('#navigation').accordion({ heightStyle: 'auto' }), 95, 130);
-});
+if ( $.uiBackCompat === false ) {
+ test( "{ active: -Number }", function() {
+ // TODO: fix initializing with negative value
+ var ac = $( "#list1" ).accordion({
+// active: -1
+ });
+// equals( ac.accordion( "option", "active" ), 2 );
+// state( ac, 0, 0, 1 );
+
+ ac.accordion( "option", "active", -2 );
+ equals( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+
+ ac.accordion( "option", "active", -10 );
+ equals( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+
+ ac.accordion( "option", "active", -3 );
+ equals( ac.accordion( "option", "active" ), 0 );
+ state( ac, 1, 0, 0 );
+ });
+}
+
+// TODO: add animation tests
-test("{ heightStyle: 'content' }", function() {
- var accordion = $('#navigation').accordion({ heightStyle: 'content' });
- var sizes = [];
- accordion.find(".ui-accordion-content").each(function() {
- sizes.push($(this).height());
+test( "{ collapsible: false }", function() {
+ var ac = $( "#list1" ).accordion({
+ active: 1
});
- ok( sizes[0] >= 70 && sizes[0] <= 90, "was " + sizes[0] );
- ok( sizes[1] >= 98 && sizes[1] <= 126, "was " + sizes[1] );
- ok( sizes[2] >= 42 && sizes[2] <= 54, "was " + sizes[2] );
-});
-test("{ collapsible: false }, default", function() {
- var ac = $("#list1").accordion();
- ac.accordion("option", "active", false);
- state(ac, 1, 0, 0);
+ ac.accordion( "option", "active", false );
+ equal( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+
+ ac.find( ".ui-accordion-header" ).eq( 1 ).click();
+ equal( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
});
-test("{ collapsible: true }", function() {
- var ac = $("#list1").accordion({
+test( "{ collapsible: true }", function() {
+ var ac = $( "#list1" ).accordion({
active: 1,
collapsible: true
});
- var header = $('#list1 .ui-accordion-header:eq(1)').click();
- equals( $("#list1").accordion('option', 'active'), false);
- state(ac, 0, 0, 0);
+
+ // TODO: fix setting active to false
+// ac.accordion( "option", "active", false );
+// equal( ac.accordion( "option", "active" ), false );
+// state( ac, 0, 0, 0 );
+
+ ac.accordion( "option", "active", 1 );
+ equal( ac.accordion( "option", "active" ), 1 );
+ state( ac, 0, 1, 0 );
+
+ ac.find( ".ui-accordion-header" ).eq( 1 ).click();
+ equals( ac.accordion( "option", "active" ), false );
+ state( ac, 0, 0, 0 );
});
-test("{ heightStyle: 'fill' }", function() {
- $("#navigationWrapper").height(500);
- equalHeights($('#navigation').accordion({ heightStyle: 'fill' }), 446, 458);
+// TODO: add event tests
+
+// TODO: add more header tests
+test( "{ header: default }", function() {
+ // default: > li > :first-child,> :not(li):even
+ // > :not(li):even
+ state( $( "#list1" ).accordion(), 1, 0, 0);
+ // > li > :first-child
+ state( $( "#navigation" ).accordion(), 1, 0, 0);
});
-test("{ header: '> li > :first-child,> :not(li):even' }, default", function() {
- state($("#list1").accordion(), 1, 0, 0);
- state($("#navigation").accordion(), 1, 0, 0);
+test( "{ heightStyle: 'auto' }", function() {
+ var ac = $( "#navigation" ).accordion({ heightStyle: "auto" });
+ equalHeights( ac, 95, 130 );
});
-test("{ icons: false }", function() {
- var list = $("#list1");
- function icons(on) {
- same($("span.ui-icon", list).length, on ? 3 : 0);
- same( list.hasClass("ui-accordion-icons"), on );
- }
- list.accordion();
- icons(true);
- list.accordion("destroy").accordion({
- icons: false
- });
- icons(false);
- list.accordion("option", "icons", $.ui.accordion.prototype.options.icons);
- icons(true);
- list.accordion("option", "icons", false);
- icons(false);
+test( "{ heightStyle: 'content' }", function() {
+ var ac = $( "#navigation" ).accordion({ heightStyle: "content" });
+ var sizes = ac.find( ".ui-accordion-content" ).map(function() {
+ return $( this ).height();
+ }).get();
+ ok( sizes[ 0 ] >= 70 && sizes[ 0 ] <= 90, "was " + sizes[ 0 ] );
+ ok( sizes[ 1 ] >= 98 && sizes[ 1 ] <= 126, "was " + sizes[ 1 ] );
+ ok( sizes[ 2 ] >= 42 && sizes[ 2 ] <= 54, "was " + sizes[ 2 ] );
});
-test("{ icons: { activeHeader : 'test' } }", function() {
- var list = $("#list1");
- list.accordion( { icons: { "activeHeader": "test" } } );
- equals( $( "#list1 span.test" ).length, 1);
- list.accordion("option", "icons", { "activeHeader": "news" } );
- equals( $( "#list1 span.test" ).length, 0);
- equals( $( "#list1 span.news" ).length, 1);
+test( "{ heightStyle: 'fill' }", function() {
+ $( "#navigationWrapper" ).height( 500 );
+ var ac = $( "#navigation" ).accordion({ heightStyle: "fill" });
+ equalHeights( ac, 446, 458);
+ ac.accordion( "destroy" );
+
+ $( "<div>" ).height( 100 ).appendTo( "#navigationWrapper" );
+ ac.accordion({ heightStyle: "fill" });
+ equalHeights( ac, 346, 358 );
});
-test("{ navigation: true, navigationFilter: header }", function() {
- $("#navigation").accordion({
- navigation: true,
- navigationFilter: function() {
- return /\?p=1\.1\.3$/.test(this.href);
- }
+test( "{ icons: false }", function() {
+ var list = $( "#list1" );
+ function icons( on ) {
+ same( list.find( "span.ui-icon").length, on ? 3 : 0 );
+ same( list.hasClass( "ui-accordion-icons" ), on );
+ }
+ list.accordion();
+ icons( true );
+ list.accordion( "destroy" ).accordion({
+ icons: false
});
- equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
+ icons( false );
+ list.accordion( "option", "icons", $.ui.accordion.prototype.options.icons );
+ icons( true );
+ list.accordion( "option", "icons", false );
+ icons( false );
});
-test("{ navigation: true, navigationFilter: content }", function() {
- $("#navigation").accordion({
- navigation: true,
- navigationFilter: function() {
- return /\?p=1\.1\.3\.2$/.test(this.href);
- }
+test( "{ icons: hash }", function() {
+ var list = $( "#list1" ).accordion({
+ icons: { activeHeader: "a1", header: "h1" }
});
- equals( $("#navigation .ui-accordion-content:eq(2)").size(), 1, "third content active" );
+ 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" ) );
});
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/accordion/accordion_tickets.js b/tests/unit/accordion/accordion_tickets.js
index 98d8fbe4c..b301051da 100644
--- a/tests/unit/accordion/accordion_tickets.js
+++ b/tests/unit/accordion/accordion_tickets.js
@@ -1,8 +1,5 @@
-/*
- * accordion_tickets.js
- */
-(function($) {
+(function( $ ) {
-module("accordion: tickets");
+module( "accordion: tickets", accordionSetupTeardown() );
-})(jQuery);
+}( jQuery ) );
diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js
index d152f84cd..23819d0e4 100644
--- a/tests/unit/testsuite.js
+++ b/tests/unit/testsuite.js
@@ -1,39 +1,67 @@
-function testWidgetDefaults(widget, defaults) {
- var pluginDefaults = $.extend({},
- $.ui[widget].prototype.options
- );
-
+(function() {
+
+function testWidgetDefaults( widget, defaults ) {
+ var pluginDefaults = $.ui[ widget ].prototype.options;
+
// ensure that all defaults have the correct value
- test('defined defaults', function() {
- $.each(defaults, function(key, val) {
- if ($.isFunction(val)) {
- ok(val !== undefined, key);
+ test( "defined defaults", function() {
+ $.each( defaults, function( key, val ) {
+ if ( $.isFunction( val ) ) {
+ ok( $.isFunction( pluginDefaults[ key ] ), key );
return;
}
- same(pluginDefaults[key], val, key);
+ same( pluginDefaults[ key ], val, key );
});
});
-
+
// ensure that all defaults were tested
- test('tested defaults', function() {
- $.each(pluginDefaults, function(key, val) {
- ok(key in defaults, key);
+ test( "tested defaults", function() {
+ $.each( pluginDefaults, function( key, val ) {
+ ok( key in defaults, key );
});
});
}
-function testWidgetOverrides(widget) {
- test('$.widget overrides', function() {
- $.each(['_widgetInit', 'option', '_trigger'], function(i, method) {
- ok($.Widget.prototype[method] == $.ui[widget].prototype[method],
- 'should not override ' + method);
+var privateMethods = [
+ "_createWidget",
+ "_super",
+ "_superApply",
+ "destroy",
+ "option",
+ "enable",
+ "disable",
+ "_trigger"
+];
+
+function testWidgetOverrides( widget ) {
+ test( "$.widget overrides", function() {
+ $.each( privateMethods, function( i, method ) {
+ strictEqual( $.ui[ widget ].prototype[ method ],
+ $.Widget.prototype[ method ], "should not override " + method );
});
});
}
-function commonWidgetTests(widget, settings) {
- module(widget + ": common widget");
+function testBasicUsage( widget ) {
+ test( "basic usage", function() {
+ var defaultElement = $.ui[ widget ].prototype.defaultElement;
+ $( defaultElement ).appendTo( "body" )[ widget ]().remove();
+ ok( true, "initialized on element" );
+
+ $( defaultElement ).accordion().remove();
+ ok( true, "initialized on disconnected DOMElement - never connected" );
- testWidgetDefaults(widget, settings.defaults);
- testWidgetOverrides(widget);
+ $( defaultElement ).appendTo( "body" ).remove().accordion().remove();
+ ok( true, "initialized on disconnected DOMElement - removed" );
+ });
}
+
+window.commonWidgetTests = function( widget, settings ) {
+ module( widget + ": common widget" );
+
+ testWidgetDefaults( widget, settings.defaults );
+ testWidgetOverrides( widget );
+ testBasicUsage( widget );
+};
+
+}());