diff options
author | maggiewachs <maggie@filamentgroup.com> | 2010-04-16 14:24:49 -0400 |
---|---|---|
committer | maggiewachs <maggie@filamentgroup.com> | 2010-04-16 14:24:49 -0400 |
commit | 970ed9a67a533ab44b184babf52100dfbcfa7c96 (patch) | |
tree | 423aa90362d991c62af87ec7b1a094706f46cdcd /tests/unit | |
parent | 4ffe07457cb21332e9a33c319c1f1f610e532a27 (diff) | |
parent | d1033cc2b79067f31767bfe0bb1f9a761dae9b3f (diff) | |
download | jquery-ui-970ed9a67a533ab44b184babf52100dfbcfa7c96.tar.gz jquery-ui-970ed9a67a533ab44b184babf52100dfbcfa7c96.zip |
Merge branch 'master' of github.com:jquery/jquery-ui
Diffstat (limited to 'tests/unit')
24 files changed, 343 insertions, 178 deletions
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index a7142250e..c53db8c75 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -16,6 +16,29 @@ <script type="text/javascript" src="../../jquery.simulate.js"></script> <script type="text/javascript" src="../testsuite.js"></script> + <script type="text/javascript"> + $.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 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> <script type="text/javascript" src="accordion_events.js"></script> @@ -25,8 +48,7 @@ <style> #main { font-size: 10pt; font-family: 'trebuchet ms', verdana, arial; } - #main h2 { margin: 0; } - #main ul, #main li { padding: 0; } + #list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; } </style> </head> <body> @@ -39,37 +61,39 @@ <div id="main" style="position: absolute; top: -10000px; left: -10000px;"> - <div id="list1"> - <a>There is one obvious advantage:</a> - <div> - <p> - You've seen it coming! - <br/> - Buy now and get nothing for free! - <br/> - Well, at least no free beer. Perhaps a bear, if you can afford it. - </p> - </div> - <a>Now that you've got...</a> - <div> - <p> - your bear, you have to admit it! - <br/> - No, we aren't selling bears. - </p> - <p> - We could talk about renting one. - </p> - </div> - <a>Rent one bear, ...</a> - <div> - <p> - get two for three beer. - </p> - <p> - And now, for something completely different. - </p> - </div> + <div> + <div id="list1" class="foo"> + <a class="bar">There is one obvious advantage:</a> + <div class="foo"> + <p> + You've seen it coming! + <br/> + Buy now and get nothing for free! + <br/> + Well, at least no free beer. Perhaps a bear, if you can afford it. + </p> + </div> + <a class="bar">Now that you've got...</a> + <div class="foo"> + <p> + your bear, you have to admit it! + <br/> + No, we aren't selling bears. + </p> + <p> + We could talk about renting one. + </p> + </div> + <a class="bar">Rent one bear, ...</a> + <div class="foo"> + <p> + get two for three beer. + </p> + <p> + And now, for something completely different. + </p> + </div> + </div> </div> <div id="navigationWrapper"> diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js index 47d2509e6..2bef43149 100644 --- a/tests/unit/accordion/accordion_core.js +++ b/tests/unit/accordion/accordion_core.js @@ -5,17 +5,6 @@ (function($) { -$.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).is(":visible") ? 1 : 0 ); - }); - same(args, result) -} - module("accordion: core"); test("handle click on header-descendant", function() { diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index 6761d24a6..73faff27c 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -3,15 +3,6 @@ */ (function($) { -function state(accordion) { - var expected = $.makeArray(arguments).slice(1); - var actual = []; - $.each(expected, function(i, n) { - actual.push( accordion.find(".ui-accordion-content").eq(i).is(":visible") ? 1 : 0 ); - }); - same(actual, expected) -} - module("accordion: methods"); test("init", function() { @@ -40,21 +31,13 @@ test("init", function() { }); test("destroy", function() { - $("<div></div>").appendTo('body').accordion().accordion("destroy").remove(); - ok(true, '.accordion("destroy") called on element'); - - $([]).accordion().accordion("destroy").remove(); - ok(true, '.accordion("destroy") called on empty collection'); - - $('<div></div>').accordion().accordion("destroy").remove(); - ok(true, '.accordion("destroy") called on disconnected DOMElement'); - - $('<div></div>').accordion().accordion("destroy").accordion("foo").remove(); - ok(true, 'arbitrary method called after destroy'); - - var expected = $('<div></div>').accordion(), - actual = expected.accordion('destroy'); - equals(actual, expected, 'destroy is chainable'); + 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 ); }); test("enable", function() { @@ -124,8 +107,7 @@ test("activate, string expression", function() { ac.accordion("activate", ":last"); state(ac, 0, 0, 1); }); -//[ 0, 1, 1 ] result: [ 0, 0, 1 ] -//[ 0, 1, 1] result: [ 0, 0, 1] + test("activate, jQuery or DOM element", function() { var ac = $('#list1').accordion({ active: $("#list1 a:last") }); state(ac, 0, 0, 1); @@ -136,24 +118,14 @@ test("activate, jQuery or DOM element", function() { }); test("resize", function() { - var expected = $('#list1').accordion(); - - 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()); + var expected = $('#navigation').parent().height(300).end().accordion({ + fillSpace: true }); - same(sizes, sizes2); + equalHeights(expected, 246, 258); - expected.find(".ui-accordion-content:first").height(500) - var sizes3 = []; + expected.parent().height(500); + expected.accordion("resize"); + equalHeights(expected, 446, 458); }); })(jQuery); diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 0782b4bb7..499fec383 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -3,16 +3,6 @@ */ (function($) { -function state(accordion) { - var expected = $.makeArray(arguments).slice(1); - var actual = []; - $.each(expected, function(i, n) { - actual.push( accordion.find(".ui-accordion-content").eq(i).is(":visible") ? 1 : 0 ); - }); - same(actual, expected) -} - - module("accordion: options"); test("{ active: first child }, default", function() { @@ -76,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() { @@ -105,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(), 362 ); - equals( $('#navigation > li:eq(1) > ul').height(), 362 ); - equals( $('#navigation > li:eq(2) > ul').height(), 362 ); + 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 ccbe66c1b..a8924e192 100644 --- a/tests/unit/autocomplete/autocomplete_events.js +++ b/tests/unit/autocomplete/autocomplete_events.js @@ -12,7 +12,7 @@ module("autocomplete: events", { var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"]; test("all events", function() { - expect(11); + expect(12); var ac = $("#autocomplete").autocomplete({ delay: 0, source: data, @@ -34,21 +34,39 @@ test("all events", function() { same(event.type, "autocompleteselect"); same(ui.item, {label:"java", value:"java"}); }, - change: function(event) { + change: function(event, ui) { same(event.type, "autocompletechange"); + same(ui.item, {label:"java", value:"java"}); same( $(".ui-menu:visible").length, 0 ); + start(); } }); stop(); - ac.val("ja").keydown(); + ac.focus().val("ja").keydown(); setTimeout(function() { same( $(".ui-menu:visible").length, 1 ); ac.simulate("keydown", { keyCode: $.ui.keyCode.DOWN }); ac.simulate("keydown", { keyCode: $.ui.keyCode.ENTER }); - start(); + $.browser.msie ? ac.simulate("blur") : ac.blur(); }, 50); }); +test("change without selection", function() { + expect(2); + stop(); + var ac = $("#autocomplete").autocomplete({ + delay: 0, + source: data, + change: function(event, ui) { + same(event.type, "autocompletechange"); + same(ui.item, null); + start(); + } + }); + ac.triggerHandler("focus"); + ac.val("ja").triggerHandler("blur"); +}); + test("cancel search", function() { expect(6); var first = true; diff --git a/tests/unit/autocomplete/autocomplete_methods.js b/tests/unit/autocomplete/autocomplete_methods.js index 5c20a6c95..05a7d6e14 100644 --- a/tests/unit/autocomplete/autocomplete_methods.js +++ b/tests/unit/autocomplete/autocomplete_methods.js @@ -13,8 +13,11 @@ module("autocomplete: methods", { test("destroy", function() { var beforeHtml = $("#autocomplete").parent().html(); var afterHtml = $("#autocomplete").autocomplete().autocomplete("destroy").parent().html(); - // TODO can't use same, as that would insert the markup unescaped into the test results, screwing up other tests - ok( beforeHtml == afterHtml ); + // 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" ); }) var data = ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"]; diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js index 6639e9014..c5aa7c961 100644 --- a/tests/unit/autocomplete/autocomplete_options.js +++ b/tests/unit/autocomplete/autocomplete_options.js @@ -120,7 +120,7 @@ function source_test(source, async) { } if (async) { stop(); - setTimeout(result, 100); + $(document).one("ajaxStop", result); } else { result(); } diff --git a/tests/unit/button/button_methods.js b/tests/unit/button/button_methods.js index 1fcd836b8..a83a73ba4 100644 --- a/tests/unit/button/button_methods.js +++ b/tests/unit/button/button_methods.js @@ -9,7 +9,11 @@ module("button: methods"); test("destroy", function() { var beforeHtml = $("#button").parent().html(); var afterHtml = $("#button").button().button("destroy").parent().html(); - same( beforeHtml, afterHtml ); + // Opera 9 outputs role="" instead of removing the attribute like everyone else + if ($.browser.opera) { + afterHtml = afterHtml.replace(/ role=""/g, ""); + } + equal( afterHtml, beforeHtml ); }); })(jQuery); diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index eb0d2f930..468c962e5 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -15,6 +15,18 @@ <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 a48f3c092..2be472a50 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -13,7 +13,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="draggable_core.js"></script> <script type="text/javascript" src="draggable_defaults.js"></script> @@ -21,6 +20,18 @@ <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"> + // 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 9f2c14a1d..c15992bcd 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -14,7 +14,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="droppable_core.js"></script> <script type="text/javascript" src="droppable_defaults.js"></script> @@ -22,6 +21,18 @@ <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"> + // 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.html b/tests/unit/position/position.html index 5a54e44c9..ca5f2585d 100644 --- a/tests/unit/position/position.html +++ b/tests/unit/position/position.html @@ -43,5 +43,9 @@ <div style="position: absolute; height: 5000px; width: 5000px;"></div> +<div id="bug-5280" style="height: 30px; width: 201px;"> + <div style="width: 50px; height: 10px;"></div> +</div> + </body> </html> diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 4d2716ced..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({ @@ -330,4 +332,22 @@ test("collision: none, with offset", function() { }, { top: -13, left: -12 }, "left top, negative offset"); }); +//test('bug #5280: consistent results (avoid fractional values)', function() { +// var wrapper = $('#bug-5280'), +// elem = wrapper.children(), +// offset1 = elem.position({ +// my: 'center', +// at: 'center', +// of: wrapper, +// collision: 'none' +// }).offset(), +// offset2 = elem.position({ +// my: 'center', +// at: 'center', +// of: wrapper, +// collision: 'none' +// }).offset(); +// same(offset1, offset2); +//}); + })(jQuery); 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 fe100d2aa..0f4f91aae 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.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="resizable_core.js"></script> <script type="text/javascript" src="resizable_defaults.js"></script> @@ -23,6 +22,18 @@ <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"> + // 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 74a10584a..278d4dde3 100644 --- a/tests/unit/selectable/selectable.html +++ b/tests/unit/selectable/selectable.html @@ -13,7 +13,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="selectable_core.js"></script> <script type="text/javascript" src="selectable_defaults.js"></script> @@ -21,6 +20,18 @@ <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"> + // 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/slider/slider_events.js b/tests/unit/slider/slider_events.js index fb9af8155..d7c146d84 100644 --- a/tests/unit/slider/slider_events.js +++ b/tests/unit/slider/slider_events.js @@ -3,45 +3,54 @@ */ (function($) { -var el; - module( "slider: events" ); -test( "start", function() { - ok( false, "missing test - untested code is broken code." ); -}); - -test( "slide", function() { - ok( false, "missing test - untested code is broken code." ); -}); - //Specs from http://wiki.jqueryui.com/Slider#specs //"change callback: triggers when the slider has stopped moving and has a new // value (even if same as previous value), via mouse(mouseup) or keyboard(keyup) // or value method/option" -test( "change", function() { - expect(8); +test( "mouse based interaction", function() { + expect(4); - var handle; - // Test mouseup at end of handle slide (mouse) - el = $( "<div></div>" ) + var el = $( "<div></div>" ) .appendTo( "body" ) .slider({ + start: function(event, ui) { + equals( event.originalEvent.type, "mousedown", "start triggered by mousedown" ); + }, + slide: function(event, ui) { + equals( event.originalEvent.type, "mousemove", "slider triggered by mousemove" ); + }, + stop: function(event, ui) { + equals( event.originalEvent.type, "mouseup", "stop triggered by mouseup" ); + }, change: function(event, ui) { - ok( true, "change triggered by mouseup at end of handle slide (mouse)" ); + equals( event.originalEvent.type, "mouseup", "change triggered by mouseup" ); } }); el.find( ".ui-slider-handle" ).eq( 0 ) .simulate( "drag", { dx: 10, dy: 10 } ); - reset(); +}); +test( "keyboard based interaction", function() { + expect(3); + // Test keyup at end of handle slide (keyboard) - el = $( "<div></div>" ) + var el = $( "<div></div>" ) .appendTo( "body" ) .slider({ + start: function(event, ui) { + equals( event.originalEvent.type, "keydown", "start triggered by keydown" ); + }, + slide: function(event, ui) { + ok( false, "Slider never triggered by keys" ); + }, + stop: function(event, ui) { + equals( event.originalEvent.type, "keyup", "stop triggered by keyup" ); + }, change: function(event, ui) { - ok( true, "change triggered by keyup at end of handle slide (keyboard)" ); + equals( event.originalEvent.type, "keyup", "change triggered by keyup" ); } }); @@ -50,9 +59,12 @@ test( "change", function() { .simulate( "keypress", { keyCode: $.ui.keyCode.LEFT } ) .simulate( "keyup", { keyCode: $.ui.keyCode.LEFT } ); - reset(); +}); +test( "programmatic event triggers", function() { + expect(6); + // Test value method - el = $( "<div></div>" ) + var el = $( "<div></div>" ) .slider({ change: function(event, ui) { ok( true, "change triggered by value method" ); @@ -94,8 +106,4 @@ test( "change", function() { }); -test( "stop", function() { - ok( false, "missing test - untested code is broken code." ); -}); - }( jQuery ) ); diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index 88eb26a8f..b9a766539 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -11,10 +11,6 @@ function handle() { module("slider: options"); -test("animate", function() { - ok(false, "missing test - untested code is broken code."); -}); - test("max", function() { el = $('<div></div>'); @@ -92,8 +88,51 @@ test("range", function() { ok(false, "missing test - untested code is broken code."); }); +//spec: http://wiki.jqueryui.com/Slider#specs +// value option/method: the value option is not restricted by min/max/step. +// What is returned by the value method is restricted by min (>=), max (<=), and step (even multiple) test("step", function() { - ok(false, "missing test - untested code is broken code."); + var el = $('<div></div>').slider({ + min: 0, + value: 0, + step: 10, + max: 100, + }); + equals( el.slider("value"), 0 ); + + el.slider("value", 1); + equals( el.slider("value"), 0 ); + + el.slider("value", 9); + equals( el.slider("value"), 10 ); + + el.slider("value", 11); + equals( el.slider("value"), 10 ); + + el.slider("value", 19); + equals( el.slider("value"), 20 ); + +el = $('<div></div>').slider({ + min: 0, + value: 0, + step: 20, + max: 100, + }); + el.slider("value", 0); + + el.slider("option", "value", 1); + equals( el.slider("value"), 0 ); + + el.slider("option", "value", 9); + equals( el.slider("value"), 0 ); + + el.slider("option", "value", 11); + equals( el.slider("value"), 20 ); + + el.slider("option", "value", 19); + equals( el.slider("value"), 20 ); + + el.slider('destroy'); }); test("value", function() { diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index 2a50f85a1..ad5cdca6d 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -13,7 +13,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="sortable_core.js"></script> <script type="text/javascript" src="sortable_defaults.js"></script> @@ -21,6 +20,18 @@ <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"> + // 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_core.js b/tests/unit/tabs/tabs_core.js index 20ab2b1fd..652788bba 100644 --- a/tests/unit/tabs/tabs_core.js +++ b/tests/unit/tabs/tabs_core.js @@ -35,19 +35,21 @@ test('ajax', function() { selected: 2, load: function() { // spinner: default spinner - equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed"); - equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed"); - el.tabs('destroy'); - el.tabs({ - selected: 2, - spinner: '<img src="spinner.gif" alt="">', - load: function() { - // spinner: image - equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed"); - equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed"); - start(); - } - }); + setTimeout(function() { + equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed"); + equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed"); + el.tabs('destroy'); + el.tabs({ + selected: 2, + spinner: '<img src="spinner.gif" alt="">', + load: function() { + // spinner: image + equals($('li:eq(2) > a > span', el).length, 1, "should restore tab markup after spinner is removed"); + equals($('li:eq(2) > a > span', el).html(), '3', "should restore tab label after spinner is removed"); + start(); + } + }); + }, 1); } }); |