diff options
Diffstat (limited to 'tests/unit')
41 files changed, 896 insertions, 92 deletions
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index c4eee6b4c..5cb972bb7 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -6,7 +6,7 @@ <link rel="stylesheet" href="../../../themes/base/jquery.ui.accordion.css"> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script> $.uiBackCompat = false; </script> diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js index ec4ca29d5..18d2d6bfb 100644 --- a/tests/unit/accordion/accordion_core.js +++ b/tests/unit/accordion/accordion_core.js @@ -3,8 +3,8 @@ module( "accordion: core", accordionSetupTeardown() ); $.each( { div: "#list1", ul: "#navigation", dl: "#accordion-dl" }, function( type, selector ) { - expect( 4 ); test( "markup structure: " + type, function() { + expect( 4 ); var element = $( selector ).accordion(); ok( element.hasClass( "ui-accordion" ), "main element is .ui-accordion" ); equal( element.find( ".ui-accordion-header" ).length, 3, diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html index 5bfe7562b..d1294390a 100644 --- a/tests/unit/accordion/accordion_deprecated.html +++ b/tests/unit/accordion/accordion_deprecated.html @@ -6,7 +6,7 @@ <link rel="stylesheet" href="../../../themes/base/jquery.ui.accordion.css"> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script src="../../../ui/jquery.ui.core.js"></script> <script src="../../../ui/jquery.ui.widget.js"></script> <script src="../../../ui/jquery.ui.accordion.js"></script> diff --git a/tests/unit/all.html b/tests/unit/all.html new file mode 100644 index 000000000..a36c9e004 --- /dev/null +++ b/tests/unit/all.html @@ -0,0 +1,51 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>jQuery UI Test Suite</title> + + <script src="../../jquery-1.6.2.js"></script> + + <link rel="stylesheet" href="../../external/qunit.css"> + <script src="../../external/qunit.js"></script> + <script src="testsuites.js"></script> + + <script> + QUnit.testSuites([ + "accordion/accordion.html", + "accordion/accordion_deprecated.html", + "autocomplete/autocomplete.html", + "button/button.html", + "core/core.html", + "datepicker/datepicker.html", + "dialog/dialog.html", + //"draggable/draggable.html", + //"droppable/droppable.html", + "effects/effects.html", + "menu/menu.html", + "position/position.html", + "progressbar/progressbar.html", + //"resizable/resizable.html", + //"selectable/selectable.html", + "slider/slider.html", + //"sortable/sortable.html", + "spinner/spinner.html", + "tabs/tabs.html", + "tabs/tabs_deprecated.html", + "tooltip/tooltip.html", + "widget/widget.html" + ]); + </script> +</head> +<body> + +<h1 id="qunit-header">jQuery UI Test Suite</h1> +<h2 id="qunit-banner"></h2> +<div id="qunit-testrunner-toolbar"></div> +<h2 id="qunit-userAgent"></h2> +<ol id="qunit-tests"></ol> +<div id="qunit-fixture"> + +</div> +</body> +</html> diff --git a/tests/unit/autocomplete/autocomplete.html b/tests/unit/autocomplete/autocomplete.html index a69562d3f..466713efb 100644 --- a/tests/unit/autocomplete/autocomplete.html +++ b/tests/unit/autocomplete/autocomplete.html @@ -6,7 +6,7 @@ <link rel="stylesheet" href="../../../themes/base/jquery.ui.autocomplete.css"> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script src="../../../ui/jquery.ui.core.js"></script> <script src="../../../ui/jquery.ui.widget.js"></script> <script src="../../../ui/jquery.ui.position.js"></script> diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html index 700ff475f..c009d8e64 100644 --- a/tests/unit/button/button.html +++ b/tests/unit/button/button.html @@ -6,7 +6,7 @@ <link type="text/css" href="../../../themes/base/jquery.ui.button.css" rel="stylesheet" /> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.button.js"></script> diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js index 5b25ecd63..a3ab5ae10 100644 --- a/tests/unit/button/button_options.js +++ b/tests/unit/button/button_options.js @@ -5,28 +5,28 @@ module("button: options"); -test("disabled, explicity value", function() { +test("disabled, explicit value", function() { $("#radio01").button({ disabled: false }); same(false, $("#radio01").button("option", "disabled"), "disabled option set to false"); - same(false, $("#radio01").attr("disabled"), "element is disabled"); + same(false, $("#radio01").prop("disabled"), "element is disabled"); $("#radio02").button({ disabled: true }); same(true, $("#radio02").button("option", "disabled"), "disabled option set to true"); - same(true, $("#radio02").attr("disabled"), "element is not disabled"); + same(true, $("#radio02").prop("disabled"), "element is not disabled"); }); test("disabled, null", function() { $("#radio01").button({ disabled: null }); same(false, $("#radio01").button("option", "disabled"), "disabled option set to false"); - same(false, $("#radio01").attr("disabled"), "element is disabled"); + same(false, $("#radio01").prop("disabled"), "element is disabled"); - $("#radio02").attr("disabled", "disabled").button({ disabled: null }); + $("#radio02").prop("disabled", true).button({ disabled: null }); same(true, $("#radio02").button("option", "disabled"), "disabled option set to true"); - same(true, $("#radio02").attr("disabled"), "element is not disabled"); + same(true, $("#radio02").prop("disabled"), "element is not disabled"); }); test("text false without icon", function() { diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 31702dd4e..bffadc12a 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -4,7 +4,7 @@ <meta charset="UTF-8" /> <title>jQuery UI Core Test Suite</title> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> @@ -108,14 +108,6 @@ <span id="spanTabindex-50" tabindex="-50">.</span> </div> - <div> - <input id="inputTabindexfoo" tabindex="foo" /> - <input id="inputTabindex3foo" tabindex="3foo" /> - - <span id="spanTabindexfoo" tabindex="foo">.</span> - <span id="spanTabindex3foo" tabindex="3foo">.</span> - </div> - <div id="zIndex100" style="z-index: 100; position: absolute"> <div id="zIndexAutoWithParent">.</div> </div> diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index e7b7f9b6c..44888ad88 100644 --- a/tests/unit/core/selector.js +++ b/tests/unit/core/selector.js @@ -147,15 +147,6 @@ test("focusable - not natively focusable with various tabindex", function() { isFocusable('#spanTabindex-50', 'span, tabindex -50'); }); -test("focusable - invalid tabindex", function() { - expect(4); - - isFocusable('#inputTabindexfoo', 'input, tabindex foo'); - isFocusable('#inputTabindex3foo', 'input, tabindex 3foo'); - isNotFocusable('#spanTabindexfoo', 'span tabindex foo'); - isNotFocusable('#spanTabindex3foo', 'span, tabindex 3foo'); -}); - test("focusable - area elements", function() { isNotFocusable('#areaCoordsNoHref', 'coords but no href'); isFocusable('#areaCoordsHref', 'coords and href'); @@ -233,15 +224,6 @@ test("tabbable - not natively tabbable with various tabindex", function() { isNotTabbable('#spanTabindex-50', 'span, tabindex -50'); }); -test("tabbable - invalid tabindex", function() { - expect(4); - - isTabbable('#inputTabindexfoo', 'input, tabindex foo'); - isTabbable('#inputTabindex3foo', 'input, tabindex 3foo'); - isNotTabbable('#spanTabindexfoo', 'span tabindex foo'); - isNotTabbable('#spanTabindex3foo', 'span, tabindex 3foo'); -}); - test("tabbable - area elements", function() { isNotTabbable('#areaCoordsNoHref', 'coords but no href'); isTabbable('#areaCoordsHref', 'coords and href'); diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html index d0c2c8c8c..9dfc78b1b 100644 --- a/tests/unit/datepicker/datepicker.html +++ b/tests/unit/datepicker/datepicker.html @@ -6,7 +6,7 @@ <link type="text/css" href="../../../themes/base/jquery.ui.datepicker.css" rel="stylesheet" /> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.datepicker.js"></script> diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js index bf48c9c8a..c7c16b610 100644 --- a/tests/unit/datepicker/datepicker_events.js +++ b/tests/unit/datepicker/datepicker_events.js @@ -41,6 +41,11 @@ test('events', function() { simulate('keydown', {keyCode: $.simulate.VK_ESC}); equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), 'Callback selected date - esc'); + var dateStr = '02/04/2008'; + inp.val(dateStr).datepicker('show'). + simulate('keydown', {keyCode: $.simulate.VK_ENTER}); + equals(dateStr, selectedDate, + 'onSelect is called after enter keydown'); // onChangeMonthYear inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}). val('').datepicker('show'); diff --git a/tests/unit/datepicker/datepicker_methods.js b/tests/unit/datepicker/datepicker_methods.js index 7ef977604..c8f1b75b2 100644 --- a/tests/unit/datepicker/datepicker_methods.js +++ b/tests/unit/datepicker/datepicker_methods.js @@ -106,15 +106,15 @@ test('enableDisable', function() { var dp = $('.ui-datepicker-inline', inl); ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - initially marked as enabled'); ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visually disabled initially'); - ok(!dp.find('select').attr('disabled'), 'Enable/disable inline - form element enabled initially'); + ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled initially'); inl.datepicker('disable'); ok(inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as disabled'); ok(dp.children().is('.ui-state-disabled'), 'Enable/disable inline - visually disabled'); - ok(dp.find('select').attr('disabled'), 'Enable/disable inline - form element disabled'); + ok(dp.find('select').prop('disabled'), 'Enable/disable inline - form element disabled'); inl.datepicker('enable'); ok(!inl.datepicker('isDisabled'), 'Enable/disable inline - now marked as enabled'); ok(!dp.children().is('.ui-state-disabled'), 'Enable/disable inline - not visiually disabled'); - ok(!dp.find('select').attr('disabled'), 'Enable/disable inline - form element enabled'); + ok(!dp.find('select').prop('disabled'), 'Enable/disable inline - form element enabled'); inl.datepicker('destroy'); }); diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index a10d1ea45..0a3d5cdac 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -469,6 +469,16 @@ test('setDate', function() { var dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0); inp.datepicker('setDate', dateAndTimeToSet); equals(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), 'Date object passed should not be changed by setDate'); + // Test onSelect callback is executed when using setDate + inp.datepicker('destroy'); + var testDate = null; + inp.datepicker({ + onSelect: function(dateText, inst) { + testDate = new Date(dateText); + } + }); + inp.datepicker('setDate', date2); + equals(date2.getTime(), testDate.getTime(), 'onSelect is called after setDate'); }); test('altField', function() { @@ -531,40 +541,37 @@ test('altField', function() { test('autoSize', function() { var inp = init('#inp'); - equals(inp.attr('size'), 20, 'Auto size - default'); + equals(inp.prop('size'), 20, 'Auto size - default'); inp.datepicker('option', 'autoSize', true); - equals(inp.attr('size'), 10, 'Auto size - mm/dd/yy'); + equals(inp.prop('size'), 10, 'Auto size - mm/dd/yy'); inp.datepicker('option', 'dateFormat', 'm/d/yy'); - equals(inp.attr('size'), 10, 'Auto size - m/d/yy'); + equals(inp.prop('size'), 10, 'Auto size - m/d/yy'); inp.datepicker('option', 'dateFormat', 'D M d yy'); - equals(inp.attr('size'), 15, 'Auto size - D M d yy'); + equals(inp.prop('size'), 15, 'Auto size - D M d yy'); inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); - equals(inp.attr('size'), 29, 'Auto size - DD, MM dd, yy'); - inp.removeAttr('size'); + equals(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy'); // French inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['fr'])); - equals(inp.attr('size'), 20, 'Auto size - fr - default'); + equals(inp.prop('size'), 29, 'Auto size - fr - default'); inp.datepicker('option', 'autoSize', true); - equals(inp.attr('size'), 10, 'Auto size - fr - dd/mm/yy'); + equals(inp.prop('size'), 10, 'Auto size - fr - dd/mm/yy'); inp.datepicker('option', 'dateFormat', 'm/d/yy'); - equals(inp.attr('size'), 10, 'Auto size - fr - m/d/yy'); + equals(inp.prop('size'), 10, 'Auto size - fr - m/d/yy'); inp.datepicker('option', 'dateFormat', 'D M d yy'); - equals(inp.attr('size'), 18, 'Auto size - fr - D M d yy'); + equals(inp.prop('size'), 18, 'Auto size - fr - D M d yy'); inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); - equals(inp.attr('size'), 28, 'Auto size - fr - DD, MM dd, yy'); - inp.removeAttr('size'); + equals(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy'); // Hebrew inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['he'])); - equals(inp.attr('size'), 20, 'Auto size - he - default'); + equals(inp.prop('size'), 28, 'Auto size - he - default'); inp.datepicker('option', 'autoSize', true); - equals(inp.attr('size'), 10, 'Auto size - he - dd/mm/yy'); + equals(inp.prop('size'), 10, 'Auto size - he - dd/mm/yy'); inp.datepicker('option', 'dateFormat', 'm/d/yy'); - equals(inp.attr('size'), 10, 'Auto size - he - m/d/yy'); + equals(inp.prop('size'), 10, 'Auto size - he - m/d/yy'); inp.datepicker('option', 'dateFormat', 'D M d yy'); - equals(inp.attr('size'), 14, 'Auto size - he - D M d yy'); + equals(inp.prop('size'), 14, 'Auto size - he - D M d yy'); inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); - equals(inp.attr('size'), 23, 'Auto size - he - DD, MM dd, yy'); - inp.removeAttr('size'); + equals(inp.prop('size'), 23, 'Auto size - he - DD, MM dd, yy'); }); test('daylightSaving', function() { @@ -702,7 +709,7 @@ test('callbacks', function() { ok(day21.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 21'); ok(day20.is('.day10'), 'Before show day - CSS 20'); ok(!day21.is('.day10'), 'Before show day - CSS 21'); - ok(day20.attr('title') == '', 'Before show day - title 20'); + ok(!day20.attr('title'), 'Before show day - title 20'); ok(day21.attr('title') == 'Divisble by 3', 'Before show day - title 21'); inp.datepicker('hide').datepicker('destroy'); }); diff --git a/tests/unit/datepicker/datepicker_tickets.js b/tests/unit/datepicker/datepicker_tickets.js index d5249f905..10647eb13 100644 --- a/tests/unit/datepicker/datepicker_tickets.js +++ b/tests/unit/datepicker/datepicker_tickets.js @@ -30,12 +30,22 @@ test('Ticket 6827: formatDate day of year calculation is wrong during day lights }); test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() { - expect(1); + var date; try{ - var date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881'); + date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881'); + ok(false, "Did not properly detect an invalid date"); }catch(e){ ok("invalid date detected"); } + + try { + date = $.datepicker.parseDate('dd/mm/yy', '18/04/1988 @ 2:43 pm'); + equal(date.getDate(), 18); + equal(date.getMonth(), 3); + equal(date.getFullYear(), 1988); + } catch(e) { + ok(false, "Did not properly parse date with extra text separated by whitespace"); + } }); })(jQuery); diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 7dc194058..fa78368ef 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -6,7 +6,7 @@ <link type="text/css" href="../../../themes/base/jquery.ui.dialog.css" rel="stylesheet" /> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../external/jquery.bgiframe-2.1.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> diff --git a/tests/unit/dialog/dialog_tickets.js b/tests/unit/dialog/dialog_tickets.js index def2452de..1cfdcefea 100644 --- a/tests/unit/dialog/dialog_tickets.js +++ b/tests/unit/dialog/dialog_tickets.js @@ -65,17 +65,15 @@ test("#6137: dialog('open') causes form elements to reset on IE7", function() { expect(2); d1 = $('<form><input type="radio" name="radio" id="a" value="a" checked="checked"></input>' + - '<input type="radio" name="radio" id="b" value="b">b</input></form>').dialog({autoOpen: false}); + '<input type="radio" name="radio" id="b" value="b">b</input></form>').appendTo( "body" ).dialog({autoOpen: false}); - d1.find('#b')[0].checked = true; + d1.find('#b').prop( "checked", true ); equal($('input:checked').val(), 'b', "checkbox b is checked"); - d2 = $('<div></div>').dialog({autoOpen: false}); - d1.dialog('open'); equal($('input:checked').val(), 'b', "checkbox b is checked"); - d1.add(d2).remove(); + d1.remove(); }); test("#6645: Missing element not found check in overlay", function(){ diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index ca5e77e78..1d949550f 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -4,7 +4,7 @@ <meta charset="UTF-8" /> <title>jQuery UI Draggable Test Suite</title> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index ebe745836..3363cb45a 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -4,7 +4,7 @@ <meta charset="UTF-8" /> <title>jQuery UI Droppable Test Suite</title> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index e3c6d2f4e..3199ba4a8 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <title>jQuery UI Core Test Suite</title> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script> $.uiBackCompat = false; </script> diff --git a/tests/unit/effects/effects_core.js b/tests/unit/effects/effects_core.js index 4c685ebb6..7c20e22fe 100644 --- a/tests/unit/effects/effects_core.js +++ b/tests/unit/effects/effects_core.js @@ -19,6 +19,18 @@ var minDuration = 15, module( "effects.core" ); +test( "Immediate Return Conditions", function() { + var hidden = $( "div.hidden" ), + count = 0; + expect( 3 ); + hidden.hide( "blind", function() { + equal( ++count, 1, "Hide on hidden returned immediately" ); + }).show().show( "blind", function() { + equal( ++count, 2, "Show on shown returned immediately" ); + }); + equal( ++count, 3, "Both Functions worked properly" ); +}); + $.each( $.effects.effect, function( effect ) { if ( effect === "transfer" ) { return; @@ -123,4 +135,19 @@ asyncTest( "animateClass works with children", function() { }}); }); +asyncTest( "animateClass clears style properties when stopped", function() { + var test = $("div.animateClass"), + style = test[0].style, + orig = style.cssText; + + expect( 2 ); + + test.addClass( "testChangeBackground", duration ); + notEqual( orig, style.cssText, "cssText is the not the same after starting animation" ); + + test.stop( true, true ); + equal( orig, style.cssText, "cssText is the same after stopping animation midway" ); + start(); +}); + })(jQuery); diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index c917f5c4b..49e33e7b1 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -6,7 +6,7 @@ <link rel="stylesheet" href="../../../themes/base/jquery.ui.all.css" type="text/css" title="ui-theme" /> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.menu.js"></script> @@ -31,7 +31,7 @@ $("#log").data("lastItem",item); $('li:eq(' + item + ') a',menu).trigger("click"); } - + </script> <script type="text/javascript" src="menu_core.js"></script> @@ -41,10 +41,12 @@ <script type="text/javascript" src="menu_options.js"></script> <script type="text/javascript" src="../swarminject.js"></script> - + <style> #qunit-fixture { font-size: 10pt; font-family: 'trebuchet ms', verdana, arial; } #list, #list1 *, #navigation, #navigation * { margin: 0; padding: 0; font-size: 12px; } + #menu3 { height: 250px; overflow: auto; } + #menu4, #menu4 ul { height: 250px; overflow: auto; } </style> </head> <body> @@ -66,6 +68,159 @@ <li class="foo"><a class="foo" href="#">Addyston</a></li> <li class="foo"><a class="foo" href="#">Adelphi</a></li> </ul> + +<ul id="menu2"> + <li class="foo"><a class="foo" href="#">Aberdeen</a></li> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Adamsville</a></li> + <li class="foo"><a class="foo" href="#">Addyston</a></li> + <li> + <a href="#">Delphi</a> + <ul> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Saarland</a></li> + <li class="foo"><a class="foo" href="#">Salzburg</a></li> + </ul> + </li> + <li class="foo"><a class="foo" href="#">Saarland</a></li> + <li> + <a href="#">Salzburg</a> + <ul> + <li> + <a href="#">Delphi</a> + <ul> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Saarland</a></li> + <li class="foo"><a class="foo" href="#">Salzburg</a></li> + </ul> + </li> + <li> + <a href="#">Delphi</a> + <ul> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Saarland</a></li> + <li class="foo"><a class="foo" href="#">Salzburg</a></li> + </ul> + </li> + <li class="foo"><a class="foo" href="#">Perch</a></li> + </ul> + </li> +</ul> + +<ul class="foo" id="menu3"> + <li class="foo"><a class="foo" href="#">Aberdeen</a></li> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Adamsville</a></li> + <li class="foo"><a class="foo" href="#">Addyston</a></li> + <li class="foo"><a class="foo" href="#">Adelphi</a></li> + <li class="foo"><a class="foo" href="#">Adena</a></li> + <li class="foo"><a class="foo" href="#">Adrian</a></li> + <li class="foo"><a class="foo" href="#">Akron</a></li> + <li class="foo"><a class="foo" href="#">Albany</a></li> + <li class="foo"><a class="foo" href="#">Alexandria</a></li> + <li class="foo"><a class="foo" href="#">Alger</a></li> + <li class="foo"><a class="foo" href="#">Alledonia</a></li> + <li class="foo"><a class="foo" href="#">Alliance</a></li> + <li class="foo"><a class="foo" href="#">Alpha</a></li> + <li class="foo"><a class="foo" href="#">Alvada</a></li> + <li class="foo"><a class="foo" href="#">Alvordton</a></li> + <li class="foo"><a class="foo" href="#">Amanda</a></li> + <li class="foo"><a class="foo" href="#">Amelia</a></li> + <li class="foo"><a class="foo" href="#">Amesville</a></li> + <li class="foo"><a class="foo" href="#">Aberdeen</a></li> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Adamsville</a></li> + <li class="foo"><a class="foo" href="#">Addyston</a></li> + <li class="foo"><a class="foo" href="#">Adelphi</a></li> + <li class="foo"><a class="foo" href="#">Adena</a></li> + <li class="foo"><a class="foo" href="#">Adrian</a></li> + <li class="foo"><a class="foo" href="#">Akron</a></li> + <li class="foo"><a class="foo" href="#">Albany</a></li> + <li class="foo"><a class="foo" href="#">Alexandria</a></li> + <li class="foo"><a class="foo" href="#">Alger</a></li> + <li class="foo"><a class="foo" href="#">Alledonia</a></li> + <li class="foo"><a class="foo" href="#">Alliance</a></li> + <li class="foo"><a class="foo" href="#">Alpha</a></li> + <li class="foo"><a class="foo" href="#">Alvada</a></li> + <li class="foo"><a class="foo" href="#">Alvordton</a></li> + <li class="foo"><a class="foo" href="#">Amanda</a></li> + <li class="foo"><a class="foo" href="#">Amelia</a></li> + <li class="foo"><a class="foo" href="#">Amesville</a></li> +</ul> + +<ul class="foo" id="menu4"> + <li class="foo"><a class="foo" href="#">Aberdeen</a></li> + <li class="foo"> + <a class="foo" href="#">Ada</a> + <ul class="foo"> + <li class="foo"><a class="foo" href="#">Aberdeen</a></li> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Adamsville</a></li> + <li class="foo"><a class="foo" href="#">Addyston</a></li> + <li class="foo"><a class="foo" href="#">Adelphi</a></li> + <li class="foo"><a class="foo" href="#">Adena</a></li> + <li class="foo"><a class="foo" href="#">Adrian</a></li> + <li class="foo"><a class="foo" href="#">Akron</a></li> + <li class="foo"><a class="foo" href="#">Albany</a></li> + <li class="foo"><a class="foo" href="#">Alexandria</a></li> + <li class="foo"><a class="foo" href="#">Alger</a></li> + <li class="foo"><a class="foo" href="#">Alledonia</a></li> + <li class="foo"><a class="foo" href="#">Alliance</a></li> + <li class="foo"><a class="foo" href="#">Alpha</a></li> + <li class="foo"><a class="foo" href="#">Alvada</a></li> + <li class="foo"><a class="foo" href="#">Alvordton</a></li> + <li class="foo"><a class="foo" href="#">Amanda</a></li> + <li class="foo"><a class="foo" href="#">Amelia</a></li> + <li class="foo"><a class="foo" href="#">Amesville</a></li> + <li class="foo"><a class="foo" href="#">Aberdeen</a></li> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Adamsville</a></li> + <li class="foo"><a class="foo" href="#">Addyston</a></li> + <li class="foo"><a class="foo" href="#">Adelphi</a></li> + <li class="foo"><a class="foo" href="#">Adena</a></li> + <li class="foo"><a class="foo" href="#">Adrian</a></li> + <li class="foo"><a class="foo" href="#">Akron</a></li> + <li class="foo"><a class="foo" href="#">Albany</a></li> + </ul> + </li> + <li class="foo"><a class="foo" href="#">Adamsville</a></li> + <li class="foo"><a class="foo" href="#">Addyston</a></li> + <li class="foo"><a class="foo" href="#">Adelphi</a></li> + <li class="foo"><a class="foo" href="#">Adena</a></li> + <li class="foo"><a class="foo" href="#">Adrian</a></li> + <li class="foo"><a class="foo" href="#">Akron</a></li> + <li class="foo"><a class="foo" href="#">Albany</a></li> + <li class="foo"><a class="foo" href="#">Alexandria</a></li> + <li class="foo"><a class="foo" href="#">Alger</a></li> + <li class="foo"><a class="foo" href="#">Alledonia</a></li> + <li class="foo"><a class="foo" href="#">Alliance</a></li> + <li class="foo"><a class="foo" href="#">Alpha</a></li> + <li class="foo"><a class="foo" href="#">Alvada</a></li> + <li class="foo"><a class="foo" href="#">Alvordton</a></li> + <li class="foo"><a class="foo" href="#">Amanda</a></li> + <li class="foo"><a class="foo" href="#">Amelia</a></li> + <li class="foo"><a class="foo" href="#">Amesville</a></li> + <li class="foo"><a class="foo" href="#">Aberdeen</a></li> + <li class="foo"><a class="foo" href="#">Ada</a></li> + <li class="foo"><a class="foo" href="#">Adamsville</a></li> + <li class="foo"><a class="foo" href="#">Addyston</a></li> + <li class="foo"><a class="foo" href="#">Adelphi</a></li> + <li class="foo"><a class="foo" href="#">Adena</a></li> + <li class="foo"><a class="foo" href="#">Adrian</a></li> + <li class="foo"><a class="foo" href="#">Akron</a></li> + <li class="foo"><a class="foo" href="#">Albany</a></li> + <li class="foo"><a class="foo" href="#">Alexandria</a></li> + <li class="foo"><a class="foo" href="#">Alger</a></li> + <li class="foo"><a class="foo" href="#">Alledonia</a></li> + <li class="foo"><a class="foo" href="#">Alliance</a></li> + <li class="foo"><a class="foo" href="#">Alpha</a></li> + <li class="foo"><a class="foo" href="#">Alvada</a></li> + <li class="foo"><a class="foo" href="#">Alvordton</a></li> + <li class="foo"><a class="foo" href="#">Amanda</a></li> + <li class="foo"><a class="foo" href="#">Amelia</a></li> + <li class="foo"><a class="foo" href="#">Amesville</a></li> +</ul> + <div id="log"></div> </div> diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js index a03bec3f6..19ac11c68 100644 --- a/tests/unit/menu/menu_events.js +++ b/tests/unit/menu/menu_events.js @@ -21,4 +21,329 @@ test("handle click on menu", function() { equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid."); }); +test( "handle blur: click", function() { + expect( 4 ); + var $menu = $( "#menu1" ).menu({ + focus: function( event, ui ) { + equal( event.originalEvent.type, "click", "focus triggered 'click'" ); + equal( event.type, "menufocus", "focus event.type is 'menufocus'" ); + + }, + blur: function( event, ui ) { + equal( event.originalEvent.type, "click", "blur triggered 'click'" ); + equal( event.type, "menublur", "blur event.type is 'menublur'" ); + } + }); + + $menu.find( "li a:first" ).trigger( "click" ); + $( "<a/>", { id: "remove"} ).appendTo("body").trigger( "click" ); + + $("#remove").remove(); +}); + +test("handle keyboard navigation on menu without scroll and without submenus", function() { + expect(12); + var element = $('#menu1').menu({ + select: function(event, ui) { + log($(ui.item[0]).text()); + }, + focus: function( event, ui ) { + log($(event.target).find(".ui-state-focus").parent().index()); + } + }); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equals( $("#log").html(), "0,keydown,", "Keydown UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equals( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "4,keydown,", "Keydown PAGE_DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); + equals( $("#log").html(), "4,keydown,", "Keydown END"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); + equals( $("#log").html(), "0,keydown,", "Keydown HOME"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equals( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER"); +}); + +asyncTest("handle keyboard navigation on menu without scroll and with submenus", function() { + expect(14); + var element = $('#menu2').menu({ + select: function(event, ui) { + log($(ui.item[0]).text()); + }, + focus: function( event, ui ) { + log($(event.target).find(".ui-state-focus").parent().index()); + } + }); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equals( $("#log").html(), "0,keydown,", "Keydown UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + + setTimeout( function() { + equals( $("#log").html(), "0,4,3,2,1,keydown,", "Keydown RIGHT (open submenu)"); + }, 50); + + setTimeout( function() { + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equals( $("#log").html(), "4,keydown,", "Keydown LEFT (close submenu)"); + + //re-open submenu + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + + setTimeout( function() { + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "2,keydown,", "Keydown PAGE_DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); + equals( $("#log").html(), "2,keydown,", "Keydown END"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); + equals( $("#log").html(), "0,keydown,", "Keydown HOME"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equals( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + + setTimeout( function() { + equals( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equals( $("#log").html(), "Ada,keydown,", "Keydown ENTER (select item)"); + + start(); + }, 200); + }, 150); + }, 100); + +}); + +test("handle keyboard navigation on menu with scroll and without submenus", function() { + expect(14); + var element = $('#menu3').menu({ + select: function(event, ui) { + log($(ui.item[0]).text()); + }, + focus: function( event, ui ) { + log($(event.target).find(".ui-state-focus").parent().index()); + } + }); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equals( $("#log").html(), "0,keydown,", "Keydown UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + equals( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "10,keydown,", "Keydown PAGE_UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); + equals( $("#log").html(), "37,keydown,", "Keydown END"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); + equals( $("#log").html(), "0,keydown,", "Keydown HOME"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equals( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER"); +}); + +asyncTest("handle keyboard navigation on menu with scroll and with submenus", function() { + expect(14); + var element = $('#menu4').menu({ + select: function(event, ui) { + log($(ui.item[0]).text()); + }, + focus: function( event, ui ) { + log($(event.target).find(".ui-state-focus").parent().index()); + } + }); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equals( $("#log").html(), "1,0,keydown,", "Keydown DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equals( $("#log").html(), "0,keydown,", "Keydown UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + + setTimeout( function() { + equals( $("#log").html(), "0,1,keydown,", "Keydown RIGHT (open submenu)"); + }, 50); + + setTimeout( function() { + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } ); + equals( $("#log").html(), "1,keydown,", "Keydown LEFT (close submenu)"); + + //re-open submenu + element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } ); + + setTimeout( function() { + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } ); + equals( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "10,keydown,", "Keydown PAGE_UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } ); + equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.END } ); + equals( $("#log").html(), "27,keydown,", "Keydown END"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } ); + equals( $("#log").html(), "0,keydown,", "Keydown HOME"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); + equals( $("#log").html(), "1,keydown,", "Keydown ESCAPE (close submenu)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + + setTimeout( function() { + equals( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)"); + + log("keydown",true); + element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ); + equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER (select item)"); + + start(); + }, 200); + }, 150); + }, 100); + +}); + })(jQuery); diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html index d71bae497..fe8a21f06 100644 --- a/tests/unit/position/position.html +++ b/tests/unit/position/position.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <title>jQuery UI Position Test Suite</title> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script> $.uiBackCompat = false; </script> diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index bd8e58612..fd6e643e9 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -435,6 +435,87 @@ test( "collision: flip, with margin", function() { }, { top: 0, left: 0 }, "right bottom" ); }); +test( "addClass: flipped left", function() { + var elem = $( "#elx" ).position( { + my: "left center", + of: window, + collision: "flip", + at: "right center" + }); + + same( elem.hasClass( 'ui-flipped-left' ), true, 'Has ui-flipped-left class' ); + + elem.position( { + my: "right center", + of: window, + collision: "flip", + at: "left center" + }) + + same( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' ); +}); + +test( "addClass: flipped top", function() { + var elem = $( "#elx" ).position( { + my: "left top", + of: window, + collision: "flip", + at: "right bottom" + }); + + same( elem.hasClass( 'ui-flipped-top' ), true, 'Has ui-flipped-top class' ); + + elem.position( { + my: "left bottom", + of: window, + collision: "flip", + at: "right top" + }); + + same( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' ); +}); + +test( "addClass: flipped right", function() { + var elem = $( "#elx" ).position( { + my: "right center", + of: window, + collision: "flip", + at: "left center" + }); + + same( elem.hasClass( 'ui-flipped-right' ), true, 'Has ui-flipped-right class' ); + + elem.position( { + my: "left center", + of: window, + collision: "flip", + at: "right center" + }); + + same( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' ); + +}); + +test( "addClass: flipped bottom", function() { + var elem = $( "#elx" ).position( { + my: "left bottom", + of: window, + collision: "flip", + at: "right top" + }); + + same( elem.hasClass( 'ui-flipped-bottom' ), true, 'Has ui-flipped-bottom class' ); + + elem.position( { + my: "left top", + of: window, + collision: "flip", + at: "right bottom" + }); + + same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' ); +}); + //test( "bug #5280: consistent results (avoid fractional values)", function() { // var wrapper = $( "#bug-5280" ), // elem = wrapper.children(), diff --git a/tests/unit/position/position_core_within.js b/tests/unit/position/position_core_within.js index 567c17192..bfb913335 100644 --- a/tests/unit/position/position_core_within.js +++ b/tests/unit/position/position_core_within.js @@ -438,4 +438,99 @@ test( "collision: flip, with margin", function() { }, { top: addTop + 0, left: addLeft + 0 }, "right bottom" ); }); +test( "addClass: flipped left", function() { + var within = $("#within-container"); + + var elem = $( "#elx" ).position( { + my: "left center", + of: within[0], + within: within, + collision: "flip", + at: "right center" + }); + + same( elem.hasClass( 'ui-flipped-left' ), true, 'Has ui-flipped-left class' ); + + elem.position( { + my: "right center", + of: within[0], + within: within, + collision: "flip", + at: "left center" + }) + + same( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' ); +}); + +test( "addClass: flipped top", function() { + var within = $("#within-container"); + + var elem = $( "#elx" ).position( { + my: "left top", + of: within[0], + within: within, + collision: "flip", + at: "right bottom" + }); + + same( elem.hasClass( 'ui-flipped-top' ), true, 'Has ui-flipped-top class' ); + + elem.position( { + my: "left bottom", + of: within[0], + within: within, + collision: "flip", + at: "right top" + }); + + same( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' ); +}); + +test( "addClass: flipped right", function() { + var within = $("#within-container"); + + var elem = $( "#elx" ).position( { + my: "right center", + of: within[0], + within: within, + collision: "flip", + at: "left center" + }); + + same( elem.hasClass( 'ui-flipped-right' ), true, 'Has ui-flipped-right class' ); + + elem.position( { + my: "left center", + of: within[0], + within: within, + collision: "flip", + at: "right center" + }); + + same( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' ); + +}); + +test( "addClass: flipped bottom", function() { + var within = $("#within-container"); + + var elem = $( "#elx" ).position( { + my: "left bottom", + of: window, + collision: "flip", + at: "right top" + }); + + same( elem.hasClass( 'ui-flipped-bottom' ), true, 'Has ui-flipped-bottom class' ); + + elem.position( { + my: "left top", + of: window, + collision: "flip", + at: "right bottom" + }); + + same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' ); +}); + }( jQuery ) ); diff --git a/tests/unit/position/position_deprecated.html b/tests/unit/position/position_deprecated.html index 156235d7b..e7af7cc46 100644 --- a/tests/unit/position/position_deprecated.html +++ b/tests/unit/position/position_deprecated.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <title>jQuery UI Position Test Suite</title> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script src="../../../ui/jquery.ui.position.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> diff --git a/tests/unit/progressbar/progressbar.html b/tests/unit/progressbar/progressbar.html index 8048203f8..0e812877a 100644 --- a/tests/unit/progressbar/progressbar.html +++ b/tests/unit/progressbar/progressbar.html @@ -6,7 +6,7 @@ <link type="text/css" href="../../../themes/base/jquery.ui.progressbar.css" rel="stylesheet" /> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.progressbar.js"></script> diff --git a/tests/unit/progressbar/progressbar_core.js b/tests/unit/progressbar/progressbar_core.js index e59579634..a499d858c 100644 --- a/tests/unit/progressbar/progressbar_core.js +++ b/tests/unit/progressbar/progressbar_core.js @@ -22,7 +22,7 @@ test("accessibility", function() { equals(el.attr("aria-disabled"), "true", "aria-disabled on"); el.progressbar("enable"); // 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"); + equals(el.attr("aria-disabled"), "false", "aria-disabled off"); }); })(jQuery); diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html index cb88c6751..bb013cf9f 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.html @@ -6,7 +6,7 @@ <link type="text/css" href="../../../themes/base/jquery.ui.resizable.css" rel="stylesheet" /> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> diff --git a/tests/unit/selectable/selectable.html b/tests/unit/selectable/selectable.html index 85e843cda..a32e574a5 100644 --- a/tests/unit/selectable/selectable.html +++ b/tests/unit/selectable/selectable.html @@ -4,7 +4,7 @@ <meta charset="UTF-8" /> <title>jQuery UI Selectable Test Suite</title> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> diff --git a/tests/unit/slider/slider.html b/tests/unit/slider/slider.html index 6dc84660b..6f52b9024 100644 --- a/tests/unit/slider/slider.html +++ b/tests/unit/slider/slider.html @@ -6,7 +6,7 @@ <link type="text/css" href="../../../themes/base/jquery.ui.slider.css" rel="stylesheet" /> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index b9a766539..f0abac665 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -96,7 +96,7 @@ test("step", function() { min: 0, value: 0, step: 10, - max: 100, + max: 100 }); equals( el.slider("value"), 0 ); @@ -116,7 +116,7 @@ el = $('<div></div>').slider({ min: 0, value: 0, step: 20, - max: 100, + max: 100 }); el.slider("value", 0); diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index 2a55cf363..34b834e05 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -4,7 +4,7 @@ <meta charset="UTF-8" /> <title>jQuery UI Sortable Test Suite</title> - <script type="text/javascript" src="../../../jquery-1.5.1.js"></script> + <script type="text/javascript" src="../../../jquery-1.6.2.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.widget.js"></script> <script type="text/javascript" src="../../../ui/jquery.ui.mouse.js"></script> diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html index 1c055afd7..ded4d081d 100644 --- a/tests/unit/spinner/spinner.html +++ b/tests/unit/spinner/spinner.html @@ -5,7 +5,7 @@ <link type="text/css" href="../../../themes/base/jquery.ui.spinner.css" rel="stylesheet" />
- <script type="text/javascript" src="../../../jquery-1.5.1.js"></script>
+ <script type="text/javascript" src="../../../jquery-1.6.2.js"></script>
<script type="text/javascript" src="../../../external/jquery.mousewheel-3.0.4.js"></script>
<script type="text/javascript" src="../../../external/jquery.global.js"></script>
<script type="text/javascript" src="../../../ui/jquery.ui.core.js"></script>
diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html index 60f5e972e..38dad7460 100644 --- a/tests/unit/tabs/tabs.html +++ b/tests/unit/tabs/tabs.html @@ -6,7 +6,7 @@ <link rel="stylesheet" href="../../../themes/base/jquery.ui.tabs.css"> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script> $.uiBackCompat = false; </script> diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html index ed6518be3..f1b7f763f 100644 --- a/tests/unit/tabs/tabs_deprecated.html +++ b/tests/unit/tabs/tabs_deprecated.html @@ -6,7 +6,7 @@ <link rel="stylesheet" href="../../../themes/base/jquery.ui.tabs.css"> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script src="../../../external/jquery.cookie.js"></script> <script src="../../../ui/jquery.ui.core.js"></script> <script src="../../../ui/jquery.ui.widget.js"></script> diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index 3d9e64d60..c8afcbe79 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -82,7 +82,7 @@ window.domEqual = function( selector, modifier, message ) { var result = {}; result.nodeName = value[0].nodeName; $.each(attributes, function(index, attr) { - result[attr] = value.attr(attr); + result[attr] = value.prop(attr); }); result.children = []; var children = value.children(); diff --git a/tests/unit/testsuites.js b/tests/unit/testsuites.js new file mode 100644 index 000000000..ffe2d3cc0 --- /dev/null +++ b/tests/unit/testsuites.js @@ -0,0 +1,76 @@ +(function( $, QUnit ) { + +$.extend( QUnit, { + testSuites: function( suites ) { + $.each( suites, function( i, suite ) { + asyncTest( suite, function() { + runSuite( suite ); + }); + }); + }, + + testStart: function( data ) { + // update the test status to show which test suite is running + $( "#qunit-testresult" ).html( "Running " + data.name + "...<br> " ); + }, + + testDone: function() { + // undo the auto-expansion of failed tests + $( "#qunit-tests > li.fail" ).each(function() { + var test = $( this ); + // avoid collapsing test results that the user manually opened + if ( test.data( "auto-collapsed" ) ) { + return; + } + test.data( "auto-collapsed", true ) + .children( "ol" ).hide(); + }); + } +}); + +// generate an iframe to run the test suite and proxy the iframe's QUnit +// to pass all test info to the main page +function runSuite( suite ) { + var body = $( "body" ), + iframe = $( "<iframe>", { src: suite } ) + .css({ + width: 1000, + height: 1000 + }) + .appendTo( body ) + [0], + iframeWin = iframe.contentWindow; + + $( iframeWin ).bind( "load", function() { + var module, test, + count = 0; + + $.extend( iframeWin.QUnit, { + moduleStart: function( data ) { + // capture module name for messages + module = data.name; + }, + + testStart: function( data ) { + // capture test name for messages + test = data.name; + }, + + log: function( data ) { + // pass all test details through to the main page + var message = module + ": " + test + ": " + data.message; + expect( ++count ); + QUnit.push( data.result, data.actual, data.expected, message ); + }, + + done: function() { + // hide the iframe from the main page once the tests are done + // and start the wrapper test from the main page + $( iframe ).hide(); + start(); + } + }); + }); +} + +}( jQuery, QUnit ) ); diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html index 21eff51fd..10bd0f22e 100644 --- a/tests/unit/tooltip/tooltip.html +++ b/tests/unit/tooltip/tooltip.html @@ -6,7 +6,7 @@ <link rel="stylesheet" href="../../../themes/base/jquery.ui.tooltip.css"> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script src="../../../ui/jquery.ui.core.js"></script> <script src="../../../ui/jquery.ui.widget.js"></script> <script src="../../../ui/jquery.ui.position.js"></script> diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js index 798d55896..74fd35d84 100644 --- a/tests/unit/tooltip/tooltip_methods.js +++ b/tests/unit/tooltip/tooltip_methods.js @@ -40,7 +40,7 @@ test( "enable/disable", function() { element.tooltip( "disable" ); equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" ); - equal( tooltip.attr( "title" ), "", "title removed on disable" ); + equal( tooltip.attr( "title" ), undefined, "title removed on disable" ); element.tooltip( "open" ); equal( $( ".ui-tooltip" ).length, 0, "open does nothing when disabled" ); diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html index b06aa19f8..bd673978c 100644 --- a/tests/unit/widget/widget.html +++ b/tests/unit/widget/widget.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <title>jQuery UI Widget Test Suite</title> - <script src="../../../jquery-1.5.1.js"></script> + <script src="../../../jquery-1.6.2.js"></script> <script src="../../../ui/jquery.ui.core.js"></script> <script src="../../../ui/jquery.ui.widget.js"></script> |