diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/accordion/accordion.html | 15 | ||||
-rw-r--r-- | tests/unit/accordion/accordion_methods.js | 29 | ||||
-rw-r--r-- | tests/unit/accordion/accordion_options.js | 31 | ||||
-rw-r--r-- | tests/unit/autocomplete/autocomplete_events.js | 5 | ||||
-rw-r--r-- | tests/unit/autocomplete/autocomplete_methods.js | 4 | ||||
-rw-r--r-- | tests/unit/button/button_methods.js | 4 | ||||
-rw-r--r-- | tests/unit/core/core.html | 13 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker.html | 13 | ||||
-rw-r--r-- | tests/unit/dialog/dialog.html | 13 | ||||
-rw-r--r-- | tests/unit/draggable/draggable.html | 16 | ||||
-rw-r--r-- | tests/unit/droppable/droppable.html | 16 | ||||
-rw-r--r-- | tests/unit/position/position_core.js | 2 | ||||
-rw-r--r-- | tests/unit/progressbar/progressbar_core.js | 4 | ||||
-rw-r--r-- | tests/unit/resizable/resizable.html | 16 | ||||
-rw-r--r-- | tests/unit/selectable/selectable.html | 16 | ||||
-rw-r--r-- | tests/unit/sortable/sortable.html | 16 | ||||
-rw-r--r-- | tests/unit/sortable/sortable_methods.js | 3 | ||||
-rw-r--r-- | tests/unit/tabs/tabs.html | 13 | ||||
-rw-r--r-- | tests/unit/tabs/tabs_events.js | 41 | ||||
-rw-r--r-- | tests/unit/tabs/tabs_methods.js | 56 |
20 files changed, 226 insertions, 100 deletions
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index 3badebda9..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> @@ -55,7 +64,7 @@ <div> <div id="list1" class="foo"> <a class="bar">There is one obvious advantage:</a> - <div style="font-style: normal; " class="foo"> + <div class="foo"> <p> You've seen it coming! <br/> @@ -65,7 +74,7 @@ </p> </div> <a class="bar">Now that you've got...</a> - <div style="font-style: normal; " class="foo"> + <div class="foo"> <p> your bear, you have to admit it! <br/> @@ -76,7 +85,7 @@ </p> </div> <a class="bar">Rent one bear, ...</a> - <div style="font-style: normal; " class="foo"> + <div class="foo"> <p> get two for three beer. </p> diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index 894d1f30c..73faff27c 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -31,8 +31,12 @@ test("init", function() { }); test("destroy", function() { - var beforeHtml = $("#list1").parent().html(); + 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 ); }); @@ -114,31 +118,14 @@ test("activate, jQuery or DOM element", function() { }); test("resize", function() { - var expected = $('#list1').parent().height(300).end().accordion({ + var expected = $('#navigation').parent().height(300).end().accordion({ fillSpace: true }); - - var sizes = []; - expected.find(".ui-accordion-content").each(function() { - sizes.push($(this).outerHeight()); - }); - - var actual = expected.accordion('resize'); - equals(actual, expected, 'resize is chainable'); - - var sizes2 = []; - expected.find(".ui-accordion-content").each(function() { - sizes2.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..499fec383 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).height()); + }); + 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() { @@ -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() { diff --git a/tests/unit/autocomplete/autocomplete_events.js b/tests/unit/autocomplete/autocomplete_events.js index 28a72145e..a8924e192 100644 --- a/tests/unit/autocomplete/autocomplete_events.js +++ b/tests/unit/autocomplete/autocomplete_events.js @@ -47,7 +47,7 @@ test("all events", function() { same( $(".ui-menu:visible").length, 1 ); ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN }); ac.simulate("keydown", { keyCode: $.ui.keyCode.ENTER }); - ac.blur(); + $.browser.msie ? ac.simulate("blur") : ac.blur(); }, 50); }); @@ -63,7 +63,8 @@ test("change without selection", function() { start(); } }); - ac.focus().val("ja").blur(); + ac.triggerHandler("focus"); + ac.val("ja").triggerHandler("blur"); }); test("cancel search", function() { diff --git a/tests/unit/autocomplete/autocomplete_methods.js b/tests/unit/autocomplete/autocomplete_methods.js index 76a600fe6..05a7d6e14 100644 --- a/tests/unit/autocomplete/autocomplete_methods.js +++ b/tests/unit/autocomplete/autocomplete_methods.js @@ -13,6 +13,10 @@ module("autocomplete: methods", { test("destroy", function() { var beforeHtml = $("#autocomplete").parent().html(); var afterHtml = $("#autocomplete").autocomplete().autocomplete("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, "before/after html should be the same" ); }) diff --git a/tests/unit/button/button_methods.js b/tests/unit/button/button_methods.js index 43c02d8cc..a83a73ba4 100644 --- a/tests/unit/button/button_methods.js +++ b/tests/unit/button/button_methods.js @@ -9,6 +9,10 @@ module("button: methods"); test("destroy", function() { var beforeHtml = $("#button").parent().html(); var afterHtml = $("#button").button().button("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 ); }); diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 843344ca7..468c962e5 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -11,11 +11,22 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> <script type="text/javascript" src="core.js"></script> <script type="text/javascript" src="selector.js"></script> + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("core", function() { ok(true, "disabled core testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> + <style type="text/css"> .zindex {z-index: 100} .absolute {position: absolute} diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html index e64bc74c0..9354e7b99 100644 --- a/tests/unit/datepicker/datepicker.html +++ b/tests/unit/datepicker/datepicker.html @@ -16,7 +16,6 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> <script type="text/javascript" src="datepicker_core.js"></script> <script type="text/javascript" src="datepicker_defaults.js"></script> @@ -24,6 +23,18 @@ <script type="text/javascript" src="datepicker_methods.js"></script> <script type="text/javascript" src="datepicker_options.js"></script> <script type="text/javascript" src="datepicker_tickets.js"></script> + + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("datepicker", function() { ok(true, "disabled datepicker testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> </head> <body> diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 03ce280e3..97a5d44cd 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -19,7 +19,6 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> <script type="text/javascript" src="dialog_core.js"></script> <script type="text/javascript" src="dialog_defaults.js"></script> @@ -27,6 +26,18 @@ <script type="text/javascript" src="dialog_methods.js"></script> <script type="text/javascript" src="dialog_options.js"></script> <script type="text/javascript" src="dialog_tickets.js"></script> + + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("dialog", function() { ok(true, "disabled dialog testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> </head> <body> diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index 050d37704..2be472a50 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -13,17 +13,25 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - <!-- <script type="text/javascript" src="draggable_core.js"></script> <script type="text/javascript" src="draggable_defaults.js"></script> <script type="text/javascript" src="draggable_events.js"></script> <script type="text/javascript" src="draggable_methods.js"></script> <script type="text/javascript" src="draggable_options.js"></script> <script type="text/javascript" src="draggable_tickets.js"></script> - --> - <script type="text/javascript">test("draggable", function() { ok(true, "disabled draggable testsuite"); });</script> + + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("draggable", function() { ok(true, "disabled draggable testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> </head> <body> diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index bc9a9d416..c15992bcd 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -14,17 +14,25 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - <!-- <script type="text/javascript" src="droppable_core.js"></script> <script type="text/javascript" src="droppable_defaults.js"></script> <script type="text/javascript" src="droppable_events.js"></script> <script type="text/javascript" src="droppable_methods.js"></script> <script type="text/javascript" src="droppable_options.js"></script> <script type="text/javascript" src="droppable_tickets.js"></script> - --> - <script type="text/javascript">test("droppable", function() { ok(true, "disabled droppable testsuite"); });</script> + + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("droppable", function() { ok(true, "disabled droppable testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> </head> <body> diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 57e02da0a..3976e43ab 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -2,6 +2,8 @@ * position_core.js */ (function($) { + +module("position"); test('my, at, of', function() { $('#elx').position({ diff --git a/tests/unit/progressbar/progressbar_core.js b/tests/unit/progressbar/progressbar_core.js index 2d95ae2f6..e59579634 100644 --- a/tests/unit/progressbar/progressbar_core.js +++ b/tests/unit/progressbar/progressbar_core.js @@ -21,8 +21,8 @@ test("accessibility", function() { el.progressbar("disable"); equals(el.attr("aria-disabled"), "true", "aria-disabled on"); el.progressbar("enable"); - // FAIL: for some reason IE6 returns a boolean false instead of the string - equals(el.attr("aria-disabled"), "false", "aria-disabled off"); + // FAIL: for some reason IE6 and 7 return a boolean false instead of the string + equals(el.attr("aria-disabled"), $.browser.msie && $.browser.version == 6 || $.browser.version == 7 ? false : "false", "aria-disabled off"); }); })(jQuery); diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html index 08c4c8798..0f4f91aae 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.html @@ -15,17 +15,25 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - <!-- <script type="text/javascript" src="resizable_core.js"></script> <script type="text/javascript" src="resizable_defaults.js"></script> <script type="text/javascript" src="resizable_events.js"></script> <script type="text/javascript" src="resizable_methods.js"></script> <script type="text/javascript" src="resizable_options.js"></script> <script type="text/javascript" src="resizable_tickets.js"></script> - --> - <script type="text/javascript">test("resizable", function() { ok(true, "disabled resizable testsuite"); });</script> + + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("resizable", function() { ok(true, "disabled resizable testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> </head> <body> diff --git a/tests/unit/selectable/selectable.html b/tests/unit/selectable/selectable.html index e71d20e22..278d4dde3 100644 --- a/tests/unit/selectable/selectable.html +++ b/tests/unit/selectable/selectable.html @@ -13,17 +13,25 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - <!-- <script type="text/javascript" src="selectable_core.js"></script> <script type="text/javascript" src="selectable_defaults.js"></script> <script type="text/javascript" src="selectable_events.js"></script> <script type="text/javascript" src="selectable_methods.js"></script> <script type="text/javascript" src="selectable_options.js"></script> <script type="text/javascript" src="selectable_tickets.js"></script> - --> - <script type="text/javascript">test("selectable", function() { ok(true, "disabled selectable testsuite"); });</script> + + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("selectable", function() { ok(true, "disabled selectable testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> </head> <body> diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index f956d6df0..ad5cdca6d 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -13,17 +13,25 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> - <!-- <script type="text/javascript" src="sortable_core.js"></script> <script type="text/javascript" src="sortable_defaults.js"></script> <script type="text/javascript" src="sortable_events.js"></script> <script type="text/javascript" src="sortable_methods.js"></script> <script type="text/javascript" src="sortable_options.js"></script> <script type="text/javascript" src="sortable_tickets.js"></script> - --> - <script type="text/javascript">test("sortable", function() { ok(true, "disabled sortable testsuite"); });</script> + + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("sortable", function() { ok(true, "disabled sortable testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> </head> <body> diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index adccc8c87..c4b5cdc08 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -84,7 +84,7 @@ test("enable", function() { }); test("disable", function() { - expect(6); + expect(7); el = $("#sortable").sortable({ disabled: false }); sort($("li", el)[0], 0, 40, 2, '.sortable({ disabled: false })'); @@ -97,6 +97,7 @@ test("disable", function() { sort($("li", el)[0], 0, 40, 2, '.sortable({ disabled: false })'); el.sortable("option", "disabled", true); equals(el.sortable("option", "disabled"), true, "disabled option setter"); + ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction"); sort($("li", el)[0], 0, 40, 0, '.sortable("option", "disabled", true)'); var expected = $('<div></div>').sortable(), diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html index 1e050af97..269f47ed5 100644 --- a/tests/unit/tabs/tabs.html +++ b/tests/unit/tabs/tabs.html @@ -15,7 +15,6 @@ <link rel="stylesheet" href="../../../external/qunit.css" type="text/css"/> <script type="text/javascript" src="../../../external/qunit.js"></script> <script type="text/javascript" src="../../jquery.simulate.js"></script> - <script type="text/javascript" src="../testsuite.js"></script> <script type="text/javascript" src="tabs_core.js"></script> <script type="text/javascript" src="tabs_defaults.js"></script> @@ -23,6 +22,18 @@ <script type="text/javascript" src="tabs_methods.js"></script> <script type="text/javascript" src="tabs_options.js"></script> <script type="text/javascript" src="tabs_tickets.js"></script> + + <script type="text/javascript"> + // disable this stale testsuite for testswarm only + var url = window.location.search; + url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) ); + if ( url && url.indexOf("http") == 0 ) { + // reset config to kill previous tests; make sure testsuite.js is loaded afterwards to init the testswarm script + QUnit.init(); + test("tabs", function() { ok(true, "disabled tabs testsuite"); }); + } + </script> + <script type="text/javascript" src="../testsuite.js"></script> </head> <body> diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js index 2c0eaac18..d0bc5fee2 100644 --- a/tests/unit/tabs/tabs_events.js +++ b/tests/unit/tabs/tabs_events.js @@ -22,15 +22,17 @@ test('show', function() { uiObj = ui; } }); - ok(uiObj !== undefined, 'should fire show after init'); - equals(uiObj.tab, $('#tabs1 a')[0], 'should have tab as DOM anchor element'); - equals(uiObj.panel, $('#tabs1 div')[0], 'should have panel as DOM div element'); - equals(uiObj.index, 0, 'should have index'); - + ok(uiObj !== undefined, 'trigger callback after initialization'); + equals(uiObj.tab, $('a', el)[0], 'contain tab as DOM anchor element'); + equals(uiObj.panel, $('div', el)[0], 'contain panel as DOM div element'); + equals(uiObj.index, 0, 'contain index'); + }); test('add', function() { + // TODO move to methods, not at all event related... + var el = $('<div id="tabs"><ul></ul></div>').tabs(); equals(el.tabs('option', 'selected'), -1, 'Initially empty, no selected tab'); @@ -47,11 +49,36 @@ test('remove', function() { }); test('enable', function() { - ok(false, "missing test - untested code is broken code."); + expect(4); + + var uiObj; + el = $('#tabs1').tabs({ + disabled: [ 0, 1 ], + enable: function (event, ui) { + uiObj = ui; + } + }); + el.tabs('enable', 1); + ok(uiObj !== undefined, 'trigger callback'); + equals(uiObj.tab, $('a', el)[1], 'contain tab as DOM anchor element'); + equals(uiObj.panel, $('div', el)[1], 'contain panel as DOM div element'); + equals(uiObj.index, 1, 'contain index'); }); test('disable', function() { - ok(false, "missing test - untested code is broken code."); + expect(4); + + var uiObj; + el = $('#tabs1').tabs({ + disable: function (event, ui) { + uiObj = ui; + } + }); + el.tabs('disable', 1); + ok(uiObj !== undefined, 'trigger callback'); + equals(uiObj.tab, $('a', el)[1], 'contain tab as DOM anchor element'); + equals(uiObj.panel, $('div', el)[1], 'contain panel as DOM div element'); + equals(uiObj.index, 1, 'contain index'); }); })(jQuery); diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js index b1b5462a6..3eb627830 100644 --- a/tests/unit/tabs/tabs_methods.js +++ b/tests/unit/tabs/tabs_methods.js @@ -9,7 +9,7 @@ test('init', function() { expect(9); el = $('#tabs1').tabs(); - + ok(true, '.tabs() called on element'); ok( el.is('.ui-tabs.ui-widget.ui-widget-content.ui-corner-all'), 'attach classes to container'); ok( $('ul', el).is('.ui-tabs-nav.ui-helper-reset.ui-helper-clearfix.ui-widget-header.ui-corner-all'), 'attach classes to list' ); @@ -23,32 +23,48 @@ test('init', function() { test('destroy', function() { expect(6); - + el = $('#tabs1').tabs({ collapsible: true }); $('li:eq(2)', el).simulate('mouseover').find('a').focus(); el.tabs('destroy'); - + ok( el.is(':not(.ui-tabs, .ui-widget, .ui-widget-content, .ui-corner-all, .ui-tabs-collapsible)'), 'remove classes from container'); ok( $('ul', el).is(':not(.ui-tabs-nav, .ui-helper-reset, .ui-helper-clearfix, .ui-widget-header, .ui-corner-all)'), 'remove classes from list' ); ok( $('div:eq(1)', el).is(':not(.ui-tabs-panel, .ui-widget-content, .ui-corner-bottom, .ui-tabs-hide)'), 'remove classes to panel' ); - ok( $('li:eq(0)', el).is(':not(.ui-tabs-selected, .ui-state-active, .ui-corner-top)'), 'remove classes from active li'); + ok( $('li:eq(0)', el).is(':not(.ui-tabs-selected, .ui-state-active, .ui-corner-top)'), 'remove classes from active li'); ok( $('li:eq(1)', el).is(':not(.ui-state-default, .ui-corner-top)'), 'remove classes from inactive li'); ok( $('li:eq(2)', el).is(':not(.ui-state-hover, .ui-state-focus)'), 'remove classes from mouseovered or focused li'); }); test('enable', function() { - ok(false, "missing test - untested code is broken code."); + expect(2); + + el = $('#tabs1').tabs({ disabled: [ 0, 1 ] }); + el.tabs("enable", 1); + ok( $('li:eq(1)', el).is(':not(.ui-state-disabled)'), 'remove class from li'); + same(el.tabs('option', 'disabled'), [ ], 'update property'); }); test('disable', function() { - ok(false, "missing test - untested code is broken code."); + expect(4); + + // normal + el = $('#tabs1').tabs(); + el.tabs('disable', 1); + ok( $('li:eq(1)', el).is('.ui-state-disabled'), 'add class to li'); + same(el.tabs('option', 'disabled'), [ 1 ], 'update disabled property'); + + // attempt to disable selected has no effect + el.tabs('disable', 0); + ok( $('li:eq(0)', el).is(':not(.ui-state-disabled)'), 'not add class to li'); + same(el.tabs('option', 'disabled'), [ 1 ], 'not update property'); }); test('add', function() { expect(4); - + el = $('#tabs1').tabs(); - el.tabs('add', "#new", 'New'); + el.tabs('add', '#new', 'New'); var added = $('li:last', el).simulate('mouseover'); ok(added.is('.ui-state-hover'), 'should add mouseover handler to added tab'); @@ -56,9 +72,9 @@ test('add', function() { var other = $('li:first', el).simulate('mouseover'); ok(other.is('.ui-state-hover'), 'should not remove mouseover handler from existing tab'); other.simulate('mouseout'); - + equals($('a', added).attr('href'), '#new', 'should not expand href to full url of current page'); - + ok(false, "missing test - untested code is broken code."); }); @@ -66,25 +82,25 @@ test('remove', function() { expect(4); el = $('#tabs1').tabs(); - + el.tabs('remove', 0); equals(el.tabs('length'), 2, 'remove tab'); equals($('li a[href$="fragment-1"]', el).length, 0, 'remove associated list item'); equals($('#fragment-1').length, 0, 'remove associated panel'); - + // TODO delete tab -> focus tab to right // TODO delete last tab -> focus tab to left - + el.tabs('select', 1); el.tabs('remove', 1); - equals(el.tabs('option', 'selected'), 0, 'update selected property'); + equals(el.tabs('option', 'selected'), 0, 'update selected property'); }); test('select', function() { expect(9); - + el = $('#tabs1').tabs(); - + el.tabs('select', 1); equals(el.tabs('option', 'selected'), 1, 'should select tab'); @@ -97,11 +113,11 @@ test('select', function() { el.tabs({ collapsible: true }); el.tabs('select', -1); equals(el.tabs('option', 'selected'), -1, 'should collapse tab passing in -1'); - + el.tabs('destroy'); el.tabs({ collapsible: true }); el.tabs('select', null); - equals(el.tabs('option', 'selected'), -1, 'should collapse tab passing in null (deprecated)'); + equals(el.tabs('option', 'selected'), -1, 'should collapse tab passing in null (deprecated)'); el.tabs('select', null); equals(el.tabs('option', 'selected'), -1, 'should not select tab passing in null a second time (deprecated)'); @@ -113,7 +129,7 @@ test('select', function() { equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true'); el.tabs('select', null); equals(el.tabs('option', 'selected'), 0, 'should not collapse tab if collapsible is not set to true'); - + el.tabs('select', '#fragment-2'); equals(el.tabs('option', 'selected'), 1, 'should select tab by id'); }); @@ -128,7 +144,7 @@ test('url', function() { test('length', function() { expect(1); - + el = $('#tabs1').tabs(); equals(el.tabs('length'), $('ul a', el).length, ' should return length'); }); |