aboutsummaryrefslogtreecommitdiffstats
path: root/tests/accordion.js
diff options
context:
space:
mode:
authorRichard Worth <rdworth@gmail.com>2008-06-07 17:35:27 +0000
committerRichard Worth <rdworth@gmail.com>2008-06-07 17:35:27 +0000
commit3524ef0c26f8760615c01217045c72f9bb20dde9 (patch)
treed7fa5208fb99d2f7d074706f1eed86a6a4b53acd /tests/accordion.js
parent2ac4aa61e5167d9aa427b70fc5f1ad9b934fdf3c (diff)
downloadjquery-ui-3524ef0c26f8760615c01217045c72f9bb20dde9.tar.gz
jquery-ui-3524ef0c26f8760615c01217045c72f9bb20dde9.zip
removed extra level ui folder
Diffstat (limited to 'tests/accordion.js')
-rw-r--r--tests/accordion.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/accordion.js b/tests/accordion.js
new file mode 100644
index 000000000..c0e3edfc5
--- /dev/null
+++ b/tests/accordion.js
@@ -0,0 +1,78 @@
+module("accordion");
+
+jQuery.ui.accordion.defaults.animated = false;
+
+function state(accordion) {
+ var args = $.makeArray(arguments).slice(1);
+ $.each(args, function(i, n) {
+ equals(n, accordion.find("div").eq(i).is(":visible"));
+ });
+}
+
+test("basics", function() {
+ state($('#list1').accordion(), 1, 0, 0);
+});
+
+test("autoheight", function() {
+ $('#navigation').accordion({ header: '.head', autoHeight: false });
+ equals( 90, $('#navigation ul:first').height() );
+ equals( 126, $('#navigation ul:eq(1)').height() );
+ equals( 54, $('#navigation ul:last').height() );
+ $('#navigation').accordion("destroy").accordion({ header: '.head', autoHeight: true });
+ equals( 126, $('#navigation ul:first').height() );
+ equals( 126, $('#navigation ul:eq(1)').height() );
+ equals( 126, $('#navigation ul:last').height() );
+});
+
+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);
+ ac.accordion("activate", -1);
+ state(ac, 0, 0, 1);
+});
+
+test("activate, boolean and numeric, alwaysOpen:false", function() {
+ var ac = $('#list1').accordion({alwaysOpen: false}).accordion("activate", 2);
+ state(ac, 0, 0, 1);
+ ok("x", "----");
+ ac.accordion("activate", 0);
+ state(ac, 1, 0, 0);
+ ok("x", "----");
+ ac.accordion("activate", -1);
+ state(ac, 0, 0, 0);
+});
+
+test("activate, boolean, alwaysOpen:true", function() {
+ var ac = $('#list1').accordion().accordion("activate", 2);
+ state(ac, 0, 0, 1);
+ ac.accordion("activate", -1);
+ state(ac, 0, 0, 1);
+});
+
+test("activate, string expression", function() {
+ var ac = $('#list1').accordion({ active: ":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);
+});
+
+test("activate, jQuery or DOM element", function() {
+ var ac = $('#list1').accordion({ active: $("#list1 a:last") });
+ state(ac, 0, 0, 1);
+ ac.accordion("activate", $("#list1 a:first"));
+ state(ac, 1, 0, 0);
+ ac.accordion("activate", $("#list1 a")[1]);
+ state(ac, 0, 1, 0);
+}); \ No newline at end of file