aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjzaefferer <joern.zaefferer@gmail.com>2010-04-13 10:13:13 +0200
committerjzaefferer <joern.zaefferer@gmail.com>2010-04-13 10:13:13 +0200
commit4f4843a9fb69c95f5fba0a4b2bbf526c035a8430 (patch)
treee45bb6901b36679c1f319b27d773de90f179b884
parent53d9ac2098ab384d6cc8c116266d6c93a174b67b (diff)
downloadjquery-ui-4f4843a9fb69c95f5fba0a4b2bbf526c035a8430.tar.gz
jquery-ui-4f4843a9fb69c95f5fba0a4b2bbf526c035a8430.zip
Accordion unit tests: Remove role attribute to pass Opera 9 and adjust height tests to tolerate different results, as long as they are consistent
-rw-r--r--tests/unit/accordion/accordion.html11
-rw-r--r--tests/unit/accordion/accordion_methods.js17
-rw-r--r--tests/unit/accordion/accordion_options.js31
3 files changed, 27 insertions, 32 deletions
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html
index 7c1165fc8..c53db8c75 100644
--- a/tests/unit/accordion/accordion.html
+++ b/tests/unit/accordion/accordion.html
@@ -29,6 +29,15 @@
});
same(args, result)
}
+ function 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] );
+ same(sizes[0], sizes[1]);
+ same(sizes[0], sizes[2]);
+ }
</script>
<script type="text/javascript" src="accordion_core.js"></script>
<script type="text/javascript" src="accordion_defaults.js"></script>
@@ -39,7 +48,7 @@
<style>
#main { font-size: 10pt; font-family: 'trebuchet ms', verdana, arial; }
- #list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; list-style: none; border: 0; outline: 0; }
+ #list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; }
</style>
</head>
<body>
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index 85f037a55..73faff27c 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -33,6 +33,10 @@ test("init", function() {
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, "");
+ }
equal( afterHtml, beforeHtml );
});
@@ -117,20 +121,11 @@ test("resize", function() {
var expected = $('#navigation').parent().height(300).end().accordion({
fillSpace: true
});
-
- var sizes = [];
- expected.find(".ui-accordion-content").each(function() {
- sizes.push($(this).outerHeight());
- });
- same(sizes, [246, 246, 246]);
+ equalHeights(expected, 246, 258);
expected.parent().height(500);
expected.accordion("resize");
- var sizes2 = [];
- expected.find(".ui-accordion-content").each(function() {
- sizes2.push($(this).outerHeight());
- });
- same(sizes2, [446, 446, 446]);
+ equalHeights(expected, 446, 458);
});
})(jQuery);
diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js
index e46795993..31aabc0d1 100644
--- a/tests/unit/accordion/accordion_options.js
+++ b/tests/unit/accordion/accordion_options.js
@@ -66,17 +66,18 @@ test("{ active: Number }", function() {
});
test("{ autoHeight: true }, default", function() {
- $('#navigation').accordion({ autoHeight: true });
- equals( $('#navigation > li:eq(0) > ul').height(), 126 );
- equals( $('#navigation > li:eq(1) > ul').height(), 126 );
- equals( $('#navigation > li:eq(2) > ul').height(), 126 );
+ equalHeights($('#navigation').accordion({ autoHeight: true }), 95, 130);
});
test("{ autoHeight: false }", function() {
- $('#navigation').accordion({ autoHeight: false });
- equals( $('#navigation > li:eq(0) > ul').height(), 90 );
- equals( $('#navigation > li:eq(1) > ul').height(), 126 );
- equals( $('#navigation > li:eq(2) > ul').height(), 54 );
+ var accordion = $('#navigation').accordion({ autoHeight: false });
+ var sizes = [];
+ accordion.find(".ui-accordion-content").each(function() {
+ sizes.push($(this).outerHeight());
+ });
+ ok( sizes[0] >= 70 && sizes[0] <= 90 );
+ ok( sizes[1] >= 98 && sizes[1] <= 126 );
+ ok( sizes[2] >= 54 && sizes[2] <= 54 );
});
test("{ collapsible: false }, default", function() {
@@ -95,20 +96,10 @@ test("{ collapsible: true }", function() {
state(ac, 0, 0, 0);
});
-test("{ fillSpace: false }, default", function() {
- $("#navigationWrapper").height(500);
- $('#navigation').accordion({ fillSpace: false });
- equals( $('#navigation > li:eq(0) > ul').height(), 126 );
- equals( $('#navigation > li:eq(1) > ul').height(), 126 );
- equals( $('#navigation > li:eq(2) > ul').height(), 126 );
-});
-
+// fillSpace: false == autoHeight: true, covered above
test("{ fillSpace: true }", function() {
$("#navigationWrapper").height(500);
- $('#navigation').accordion({ fillSpace: true });
- equals( $('#navigation > li:eq(0) > ul').height(), 446 );
- equals( $('#navigation > li:eq(1) > ul').height(), 446 );
- equals( $('#navigation > li:eq(2) > ul').height(), 446 );
+ equalHeights($('#navigation').accordion({ fillSpace: true }), 446, 458);
});
test("{ header: '> li > :first-child,> :not(li):even' }, default", function() {