diff options
Diffstat (limited to 'tests/unit')
73 files changed, 685 insertions, 1223 deletions
diff --git a/tests/unit/accordion/accordion.html b/tests/unit/accordion/accordion.html index 5c9169ea3..b3b7caeae 100644 --- a/tests/unit/accordion/accordion.html +++ b/tests/unit/accordion/accordion.html @@ -8,9 +8,12 @@ <script> $.uiBackCompat = false; </script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.accordion" ], js: [ "ui/jquery.ui.core.js", @@ -20,13 +23,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script src="accordion_test_helpers.js"></script> - <script src="accordion_defaults.js"></script> + <script src="accordion_common.js"></script> <script src="accordion_core.js"></script> <script src="accordion_events.js"></script> <script src="accordion_methods.js"></script> @@ -93,7 +91,7 @@ <li><a href="?p=1.1.1.3">Amps</a></li> <li><a href="?p=1.1.1.4">Effects</a></li> <li><a href="?p=1.1.1.5">Accessories</a></li> - </ul> + </ul> </li> <li> <h2><a href="?p=1.1.2"><span>Bass</span></a></h2> @@ -105,7 +103,7 @@ <li><a href="?p=1.1.2.5">Accessories</a></li> <li><a href="?p=1.1.2.5">Accessories</a></li> <li><a href="?p=1.1.2.5">Accessories</a></li> - </ul> + </ul> </li> <li> <h2><a href="?p=1.1.3">Drums</a></h2> @@ -113,7 +111,7 @@ <li><a href="?p=1.1.3.2">Acoustic</a></li> <li><a href="?p=1.1.3.3">Electronic</a></li> <li><a href="?p=1.1.3.6">Accessories</a></li> - </ul> + </ul> </li> </ul> </div> diff --git a/tests/unit/accordion/accordion_defaults.js b/tests/unit/accordion/accordion_common.js index ef24cf25e..ef24cf25e 100644 --- a/tests/unit/accordion/accordion_defaults.js +++ b/tests/unit/accordion/accordion_common.js diff --git a/tests/unit/accordion/accordion_defaults_deprecated.js b/tests/unit/accordion/accordion_common_deprecated.js index 22d5e1289..22d5e1289 100644 --- a/tests/unit/accordion/accordion_defaults_deprecated.js +++ b/tests/unit/accordion/accordion_common_deprecated.js diff --git a/tests/unit/accordion/accordion_deprecated.html b/tests/unit/accordion/accordion_deprecated.html index 116eb43b5..dfb9fa90e 100644 --- a/tests/unit/accordion/accordion_deprecated.html +++ b/tests/unit/accordion/accordion_deprecated.html @@ -5,9 +5,12 @@ <title>jQuery UI Accordion Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.accordion" ], js: [ "ui/jquery.ui.core.js", @@ -17,13 +20,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script src="accordion_test_helpers.js"></script> - <script src="accordion_defaults_deprecated.js"></script> + <script src="accordion_common_deprecated.js"></script> <script src="accordion_core.js"></script> <script src="accordion_events.js"></script> <script src="accordion_methods.js"></script> @@ -91,7 +89,7 @@ <li><a href="?p=1.1.1.3">Amps</a></li> <li><a href="?p=1.1.1.4">Effects</a></li> <li><a href="?p=1.1.1.5">Accessories</a></li> - </ul> + </ul> </li> <li> <h2><a href="?p=1.1.2"><span>Bass</span></a></h2> @@ -103,7 +101,7 @@ <li><a href="?p=1.1.2.5">Accessories</a></li> <li><a href="?p=1.1.2.5">Accessories</a></li> <li><a href="?p=1.1.2.5">Accessories</a></li> - </ul> + </ul> </li> <li> <h2><a href="?p=1.1.3">Drums</a></h2> @@ -111,7 +109,7 @@ <li><a href="?p=1.1.3.2">Acoustic</a></li> <li><a href="?p=1.1.3.3">Electronic</a></li> <li><a href="?p=1.1.3.6">Accessories</a></li> - </ul> + </ul> </li> </ul> </div> diff --git a/tests/unit/accordion/all.html b/tests/unit/accordion/all.html index ec9c003d9..2fb783c1c 100644 --- a/tests/unit/accordion/all.html +++ b/tests/unit/accordion/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/all-active.html b/tests/unit/all-active.html index 89c10441d..b3e2fbcba 100644 --- a/tests/unit/all-active.html +++ b/tests/unit/all-active.html @@ -7,9 +7,9 @@ <script src="../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../external/qunit.css"> - <link rel="stylesheet" href="subsuiteRunner.css"> + <link rel="stylesheet" href="qunit-composite.css"> <script src="../../external/qunit.js"></script> - <script src="subsuiteRunner.js"></script> + <script src="qunit-composite.js"></script> <script> (function() { diff --git a/tests/unit/all.html b/tests/unit/all.html index e48b1ac0e..6d98df0f9 100644 --- a/tests/unit/all.html +++ b/tests/unit/all.html @@ -7,9 +7,9 @@ <script src="../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../external/qunit.css"> - <link rel="stylesheet" href="subsuiteRunner.css"> + <link rel="stylesheet" href="qunit-composite.css"> <script src="../../external/qunit.js"></script> - <script src="subsuiteRunner.js"></script> + <script src="qunit-composite.js"></script> <script> (function() { diff --git a/tests/unit/autocomplete/all.html b/tests/unit/autocomplete/all.html index 87cde75fb..e35777f65 100644 --- a/tests/unit/autocomplete/all.html +++ b/tests/unit/autocomplete/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/autocomplete/autocomplete.html b/tests/unit/autocomplete/autocomplete.html index 70d2ecfd1..571c62033 100644 --- a/tests/unit/autocomplete/autocomplete.html +++ b/tests/unit/autocomplete/autocomplete.html @@ -5,9 +5,12 @@ <title>jQuery UI Autocomplete Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.menu", "ui.autocomplete" ], js: [ "ui/jquery.ui.core.js", @@ -19,12 +22,7 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - - <script src="autocomplete_defaults.js"></script> + <script src="autocomplete_common.js"></script> <script src="autocomplete_core.js"></script> <script src="autocomplete_events.js"></script> <script src="autocomplete_methods.js"></script> diff --git a/tests/unit/autocomplete/autocomplete_defaults.js b/tests/unit/autocomplete/autocomplete_common.js index c090ce4df..c090ce4df 100644 --- a/tests/unit/autocomplete/autocomplete_defaults.js +++ b/tests/unit/autocomplete/autocomplete_common.js diff --git a/tests/unit/button/all.html b/tests/unit/button/all.html index 115743e94..6c46c9650 100644 --- a/tests/unit/button/all.html +++ b/tests/unit/button/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html index 5ec7e316a..b79ca1dc6 100644 --- a/tests/unit/button/button.html +++ b/tests/unit/button/button.html @@ -5,9 +5,12 @@ <title>jQuery UI Button Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.button" ], js: [ "ui/jquery.ui.core.js", @@ -17,13 +20,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="button_common.js"></script> <script src="button_core.js"></script> - <script src="button_defaults.js"></script> <script src="button_events.js"></script> <script src="button_methods.js"></script> <script src="button_options.js"></script> diff --git a/tests/unit/button/button_defaults.js b/tests/unit/button/button_common.js index ef22d3011..ef22d3011 100644 --- a/tests/unit/button/button_defaults.js +++ b/tests/unit/button/button_common.js diff --git a/tests/unit/core/all.html b/tests/unit/core/all.html index 78bbe9aef..e31d6905c 100644 --- a/tests/unit/core/all.html +++ b/tests/unit/core/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html index 3b1dc1fc8..272b15d2c 100644 --- a/tests/unit/core/core.html +++ b/tests/unit/core/core.html @@ -5,17 +5,15 @@ <title>jQuery UI Core Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> - <script> - loadResources({ - js: [ "ui/jquery.ui.core.js" ] - }); - </script> - <link rel="stylesheet" href="../../../external/qunit.css"> <script src="../../../external/qunit.js"></script> <script src="../../jquery.simulate.js"></script> <script src="../testsuite.js"></script> + <script> + TestHelpers.loadResources({ + js: [ "ui/jquery.ui.core.js" ] + }); + </script> <script src="core.js"></script> <script src="selector.js"></script> @@ -39,15 +37,13 @@ <ol id="qunit-tests"></ol> <div id="qunit-fixture"> -<img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10", height="10"> +<img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10" height="10" alt=""> <map name="mymap"> - <area shape="rect" coords="0,0,1,1" id="areaCoordsNoHref"> - <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaCoordsHref"> - <area shape="rect" coords="0,0,0,0" href="foo.html" id="areaCoordsNoSizeHref"> - <area href="foo.html" id="areaNoCoordsHref"> + <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaCoordsHref" alt=""> + <area href="foo.html" id="areaNoCoordsHref" alt=""> </map> <map name="mymap2"> - <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaNoImg"> + <area shape="rect" coords="1,1,2,2" href="foo.html" id="areaNoImg" alt=""> </map> <form id="formNoTabindex"></form> diff --git a/tests/unit/core/selector.js b/tests/unit/core/selector.js index 2fb78025c..4309289c9 100644 --- a/tests/unit/core/selector.js +++ b/tests/unit/core/selector.js @@ -6,24 +6,24 @@ module("core - selectors"); function isFocusable(selector, msg) { - ok($(selector).is(':focusable'), msg + " - selector " + selector + " is focusable"); + QUnit.push($(selector).is(':focusable'), null, null, msg + " - selector " + selector + " is focusable"); } function isNotFocusable(selector, msg) { - ok($(selector).length && !$(selector).is(':focusable'), msg + " - selector " + selector + " is not focusable"); + QUnit.push($(selector).length && !$(selector).is(':focusable'), null, null, msg + " - selector " + selector + " is not focusable"); } function isTabbable(selector, msg) { - ok($(selector).is(':tabbable'), msg + " - selector " + selector + " is tabbable"); + QUnit.push($(selector).is(':tabbable'), null, null, msg + " - selector " + selector + " is tabbable"); } function isNotTabbable(selector, msg) { - ok($(selector).length && !$(selector).is(':tabbable'), msg + " - selector " + selector + " is not tabbable"); + QUnit.push($(selector).length && !$(selector).is(':tabbable'), null, null, msg + " - selector " + selector + " is not tabbable"); } test("data", function() { expect(15); - + var el; function shouldHaveData(msg) { ok(el.is(':data(test)'), msg); @@ -31,56 +31,56 @@ test("data", function() { function shouldNotHaveData(msg) { ok(!el.is(':data(test)'), msg); } - + el = $('<div>'); shouldNotHaveData('data never set'); - + el = $('<div>').data('test', null); shouldNotHaveData('data is null'); - + el = $('<div>').data('test', true); shouldHaveData('data set to true'); - + el = $('<div>').data('test', false); shouldNotHaveData('data set to false'); - + el = $('<div>').data('test', 0); shouldNotHaveData('data set to 0'); - + el = $('<div>').data('test', 1); shouldHaveData('data set to 1'); - + el = $('<div>').data('test', ''); shouldNotHaveData('data set to empty string'); - + el = $('<div>').data('test', 'foo'); shouldHaveData('data set to string'); - + el = $('<div>').data('test', []); shouldHaveData('data set to empty array'); - + el = $('<div>').data('test', [1]); shouldHaveData('data set to array'); - + el = $('<div>').data('test', {}); shouldHaveData('data set to empty object'); - + el = $('<div>').data('test', {foo: 'bar'}); shouldHaveData('data set to object'); - + el = $('<div>').data('test', new Date()); shouldHaveData('data set to date'); - + el = $('<div>').data('test', /test/); shouldHaveData('data set to regexp'); - + el = $('<div>').data('test', function() {}); shouldHaveData('data set to function'); }); test("focusable - visible, enabled elements", function() { expect(18); - + isNotFocusable('#formNoTabindex', 'form'); isFocusable('#formTabindex', 'form with tabindex'); isFocusable('#visibleAncestor-inputTypeNone', 'input, no type'); @@ -103,7 +103,7 @@ test("focusable - visible, enabled elements", function() { test("focusable - disabled elements", function() { expect(9); - + isNotFocusable('#disabledElement-inputTypeNone', 'input, no type'); isNotFocusable('#disabledElement-inputTypeText', 'input, type text'); isNotFocusable('#disabledElement-inputTypeCheckbox', 'input, type checkbox'); @@ -117,23 +117,23 @@ test("focusable - disabled elements", function() { test("focusable - hidden styles", function() { expect(8); - + isNotFocusable('#displayNoneAncestor-input', 'input, display: none parent'); isNotFocusable('#displayNoneAncestor-span', 'span with tabindex, display: none parent'); - + isNotFocusable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent'); isNotFocusable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent'); - + isNotFocusable('#displayNone-input', 'input, display: none'); isNotFocusable('#visibilityHidden-input', 'input, visibility: hidden'); - + isNotFocusable('#displayNone-span', 'span with tabindex, display: none'); isNotFocusable('#visibilityHidden-span', 'span with tabindex, visibility: hidden'); }); test("focusable - natively focusable with various tabindex", function() { expect(4); - + isFocusable('#inputTabindex0', 'input, tabindex 0'); isFocusable('#inputTabindex10', 'input, tabindex 10'); isFocusable('#inputTabindex-1', 'input, tabindex -1'); @@ -142,7 +142,7 @@ test("focusable - natively focusable with various tabindex", function() { test("focusable - not natively focusable with various tabindex", function() { expect(4); - + isFocusable('#spanTabindex0', 'span, tabindex 0'); isFocusable('#spanTabindex10', 'span, tabindex 10'); isFocusable('#spanTabindex-1', 'span, tabindex -1'); @@ -150,16 +150,14 @@ test("focusable - not natively focusable with various tabindex", function() { }); test("focusable - area elements", function() { - isNotFocusable('#areaCoordsNoHref', 'coords but no href'); isFocusable('#areaCoordsHref', 'coords and href'); - isFocusable('#areaCoordsNoSizeHref', 'coords of zero px and href'); isFocusable('#areaNoCoordsHref', 'href but no coords'); isNotFocusable('#areaNoImg', 'not associated with an image'); }); test("tabbable - visible, enabled elements", function() { expect(18); - + isNotTabbable('#formNoTabindex', 'form'); isTabbable('#formTabindex', 'form with tabindex'); isTabbable('#visibleAncestor-inputTypeNone', 'input, no type'); @@ -182,7 +180,7 @@ test("tabbable - visible, enabled elements", function() { test("tabbable - disabled elements", function() { expect(9); - + isNotTabbable('#disabledElement-inputTypeNone', 'input, no type'); isNotTabbable('#disabledElement-inputTypeText', 'input, type text'); isNotTabbable('#disabledElement-inputTypeCheckbox', 'input, type checkbox'); @@ -196,23 +194,23 @@ test("tabbable - disabled elements", function() { test("tabbable - hidden styles", function() { expect(8); - + isNotTabbable('#displayNoneAncestor-input', 'input, display: none parent'); isNotTabbable('#displayNoneAncestor-span', 'span with tabindex, display: none parent'); - + isNotTabbable('#visibilityHiddenAncestor-input', 'input, visibility: hidden parent'); isNotTabbable('#visibilityHiddenAncestor-span', 'span with tabindex, visibility: hidden parent'); - + isNotTabbable('#displayNone-input', 'input, display: none'); isNotTabbable('#visibilityHidden-input', 'input, visibility: hidden'); - + isNotTabbable('#displayNone-span', 'span with tabindex, display: none'); isNotTabbable('#visibilityHidden-span', 'span with tabindex, visibility: hidden'); }); test("tabbable - natively tabbable with various tabindex", function() { expect(4); - + isTabbable('#inputTabindex0', 'input, tabindex 0'); isTabbable('#inputTabindex10', 'input, tabindex 10'); isNotTabbable('#inputTabindex-1', 'input, tabindex -1'); @@ -221,7 +219,7 @@ test("tabbable - natively tabbable with various tabindex", function() { test("tabbable - not natively tabbable with various tabindex", function() { expect(4); - + isTabbable('#spanTabindex0', 'span, tabindex 0'); isTabbable('#spanTabindex10', 'span, tabindex 10'); isNotTabbable('#spanTabindex-1', 'span, tabindex -1'); @@ -229,9 +227,7 @@ test("tabbable - not natively tabbable with various tabindex", function() { }); test("tabbable - area elements", function() { - isNotTabbable('#areaCoordsNoHref', 'coords but no href'); isTabbable('#areaCoordsHref', 'coords and href'); - isTabbable('#areaCoordsNoSizeHref', 'coords of zero px and href'); isTabbable('#areaNoCoordsHref', 'href but no coords'); isNotTabbable('#areaNoImg', 'not associated with an image'); }); diff --git a/tests/unit/datepicker/all.html b/tests/unit/datepicker/all.html index 1540705f8..c62c7c07d 100644 --- a/tests/unit/datepicker/all.html +++ b/tests/unit/datepicker/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html index 592db53cc..bfff32d32 100644 --- a/tests/unit/datepicker/datepicker.html +++ b/tests/unit/datepicker/datepicker.html @@ -5,9 +5,12 @@ <title>jQuery UI Datepicker Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.datepicker" ], js: [ "ui/jquery.ui.core.js", @@ -19,11 +22,6 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script src="datepicker_core.js"></script> <script src="datepicker_defaults.js"></script> <script src="datepicker_events.js"></script> diff --git a/tests/unit/dialog/all.html b/tests/unit/dialog/all.html index 973119c08..b1c69c6c9 100644 --- a/tests/unit/dialog/all.html +++ b/tests/unit/dialog/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/dialog/dialog.html b/tests/unit/dialog/dialog.html index 94b20a225..d804807f2 100644 --- a/tests/unit/dialog/dialog.html +++ b/tests/unit/dialog/dialog.html @@ -6,9 +6,12 @@ <script src="../../jquery.js"></script> <script src="../../../external/jquery.bgiframe-2.1.2.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.dialog" ], js: [ "ui/jquery.ui.core.js", @@ -22,13 +25,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="dialog_common.js"></script> <script src="dialog_core.js"></script> - <script src="dialog_defaults.js"></script> <script src="dialog_events.js"></script> <script src="dialog_methods.js"></script> <script src="dialog_options.js"></script> diff --git a/tests/unit/dialog/dialog_defaults.js b/tests/unit/dialog/dialog_common.js index 623908da7..623908da7 100644 --- a/tests/unit/dialog/dialog_defaults.js +++ b/tests/unit/dialog/dialog_common.js diff --git a/tests/unit/draggable/all.html b/tests/unit/draggable/all.html index 1b2a511a5..75df351ad 100644 --- a/tests/unit/draggable/all.html +++ b/tests/unit/draggable/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html index 5be71f460..09bc191c9 100644 --- a/tests/unit/draggable/draggable.html +++ b/tests/unit/draggable/draggable.html @@ -5,9 +5,12 @@ <title>jQuery UI Draggable Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core" ], js: [ "ui/jquery.ui.core.js", @@ -18,13 +21,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="draggable_common.js"></script> <script src="draggable_core.js"></script> - <script src="draggable_defaults.js"></script> <script src="draggable_events.js"></script> <script src="draggable_methods.js"></script> <script src="draggable_options.js"></script> diff --git a/tests/unit/draggable/draggable_defaults.js b/tests/unit/draggable/draggable_common.js index b47b139cd..b47b139cd 100644 --- a/tests/unit/draggable/draggable_defaults.js +++ b/tests/unit/draggable/draggable_common.js diff --git a/tests/unit/droppable/all.html b/tests/unit/droppable/all.html index 535f41521..aa24ed7e1 100644 --- a/tests/unit/droppable/all.html +++ b/tests/unit/droppable/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/droppable/droppable.html b/tests/unit/droppable/droppable.html index abf94f0c7..49ebf6beb 100644 --- a/tests/unit/droppable/droppable.html +++ b/tests/unit/droppable/droppable.html @@ -5,9 +5,12 @@ <title>jQuery UI Droppable Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core" ], js: [ "ui/jquery.ui.core.js", @@ -19,13 +22,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="droppable_common.js"></script> <script src="droppable_core.js"></script> - <script src="droppable_defaults.js"></script> <script src="droppable_events.js"></script> <script src="droppable_methods.js"></script> <script src="droppable_options.js"></script> diff --git a/tests/unit/droppable/droppable_defaults.js b/tests/unit/droppable/droppable_common.js index 985dba06d..985dba06d 100644 --- a/tests/unit/droppable/droppable_defaults.js +++ b/tests/unit/droppable/droppable_common.js diff --git a/tests/unit/effects/all.html b/tests/unit/effects/all.html index 0ef901292..59500588c 100644 --- a/tests/unit/effects/all.html +++ b/tests/unit/effects/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/effects/effects.html b/tests/unit/effects/effects.html index 06023c55d..1fd94182d 100644 --- a/tests/unit/effects/effects.html +++ b/tests/unit/effects/effects.html @@ -8,9 +8,12 @@ <script> $.uiBackCompat = false; </script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ js: [ "ui/jquery.effects.core.js", "ui/jquery.effects.blind.js", @@ -30,10 +33,6 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> <script src="effects_core.js"></script> <script src="effects_scale.js"></script> diff --git a/tests/unit/menu/all.html b/tests/unit/menu/all.html index a58e15299..475c1b717 100644 --- a/tests/unit/menu/all.html +++ b/tests/unit/menu/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html index 9a598ec8d..fca45697f 100644 --- a/tests/unit/menu/menu.html +++ b/tests/unit/menu/menu.html @@ -5,9 +5,12 @@ <title>jQuery UI Menu Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.menu" ], js: [ "ui/jquery.ui.core.js", @@ -17,14 +20,9 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script src="menu_test_helpers.js"></script> + <script src="menu_common.js"></script> <script src="menu_core.js"></script> - <script src="menu_defaults.js"></script> <script src="menu_events.js"></script> <script src="menu_methods.js"></script> <script src="menu_options.js"></script> diff --git a/tests/unit/menu/menu_defaults.js b/tests/unit/menu/menu_common.js index ddcdbebf2..ddcdbebf2 100644 --- a/tests/unit/menu/menu_defaults.js +++ b/tests/unit/menu/menu_common.js diff --git a/tests/unit/position/all.html b/tests/unit/position/all.html index fa3ecf23d..d76f9bbd8 100644 --- a/tests/unit/position/all.html +++ b/tests/unit/position/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/position/position.html b/tests/unit/position/position.html index 115adc3e9..518e1f960 100644 --- a/tests/unit/position/position.html +++ b/tests/unit/position/position.html @@ -8,20 +8,17 @@ <script> $.uiBackCompat = false; </script> - <script src="../../resource_loader.js"></script> - <script> - loadResources({ - js: [ "ui/jquery.ui.position.js" ] - }); - </script> - <link rel="stylesheet" href="../../../external/qunit.css"> <script src="../../../external/qunit.js"></script> <script src="../../jquery.simulate.js"></script> <script src="../testsuite.js"></script> + <script> + TestHelpers.loadResources({ + js: [ "ui/jquery.ui.position.js" ] + }); + </script> <script src="position_core.js"></script> - <script src="position_core_within.js"></script> <script src="../swarminject.js"></script> </head> @@ -41,29 +38,20 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6 --> <div id="qunit-fixture" style="top: 0; left: 0; z-index:1"> - <div id="within-container"> - <div id="el1" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> - <div id="el2" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> - <div id="parent" style="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px;"></div> - - <div style="position: absolute; top: 0px; left: 0px"> - <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div> - </div> - - <div style="position: absolute; top: 200px; left: 100px;"> - <div id="el-offset-100-200" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div style="position: absolute; top: 100px; left: 50px;"> - <div id="el-two-offset-150-300" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div id="el-fixed" style="position: fixed; top: 200px; left: 200px;"></div> - </div> - </div> + <div id="el1" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> + <div id="el2" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> + <div id="parent" style="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px;"></div> + <div id="within" style="position: absolute; width: 12px; height: 12px; top: 2px; left: 0px;"></div> + + <div style="position: absolute; top: 0px; left: 0px"> + <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> + <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div> + </div> - <div style="position: absolute; height: 5000px; width: 5000px;"></div> + <div style="position: absolute; height: 5000px; width: 5000px;"></div> - <div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;"> - <div id="fractions-element"></div> - </div> + <div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;"> + <div id="fractions-element"></div> </div> <div id="bug-5280" style="height: 30px; width: 201px;"> diff --git a/tests/unit/position/position_core.js b/tests/unit/position/position_core.js index 5c86e7887..0ebcabef3 100644 --- a/tests/unit/position/position_core.js +++ b/tests/unit/position/position_core.js @@ -1,13 +1,24 @@ (function( $ ) { -function scrollTopSupport() { - $( window ).scrollTop( 1 ); - return $( window ).scrollTop() === 1; -} - -module( "position" ); +var win = $( window ), + scrollTopSupport = function() { + var support = win.scrollTop( 1 ).scrollTop() === 1; + win.scrollTop( 0 ); + scrollTopSupport = function() { + return support; + }; + return support; + }; + +module( "position", { + setup: function() { + win.scrollTop( 0 ).scrollLeft( 0 ); + } +}); test( "my, at, of", function() { + expect( 4 ); + $( "#elx" ).position({ my: "left top", at: "left top", @@ -42,6 +53,8 @@ test( "my, at, of", function() { }); test( "multiple elements", function() { + expect( 3 ); + var elements = $( "#el1, #el2" ), result = elements.position({ my: "left top", @@ -58,8 +71,9 @@ test( "multiple elements", function() { }); test( "positions", function() { - var definitions = [], - offsets = { + expect( 18 ); + + var offsets = { left: 0, center: 3, right: 6, @@ -68,33 +82,32 @@ test( "positions", function() { }, start = { left: 4, top: 4 }, el = $( "#el1" ); + $.each( [ 0, 1 ], function( my ) { $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) { $.each( [ "left", "center", "right" ], function( hindex, horizontal ) { - definitions.push({ - my: my ? horizontal + " " + vertical : "left top", - at: !my ? horizontal + " " + vertical : "left top", - result: { - top: my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ], - left: my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ] - } + var _my = my ? horizontal + " " + vertical : "left top", + _at = !my ? horizontal + " " + vertical : "left top"; + el.position({ + my: _my, + at: _at, + of: "#parent", + collision: "none" }); + deepEqual( el.offset(), { + top: start.top + offsets[ vertical ] * (my ? -1 : 1), + left: start.left + offsets[ horizontal ] * (my ? -1 : 1) + }, "Position via " + QUnit.jsDump.parse({ my: _my, at: _at }) ); }); }); }); - $.each( definitions, function( index, definition ) { - el.position({ - my: definition.my, - at: definition.at, - of: "#parent", - collision: "none" - }); - deepEqual( el.offset(), definition.result, - "Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) ); - }); }); test( "of", function() { + expect( 9 + (scrollTopSupport() ? 1 : 0) ); + + var event; + $( "#elx" ).position({ my: "left top", at: "left top", @@ -141,7 +154,7 @@ test( "of", function() { left: $( document ).width() - 10 }, "document as jQuery object" ); - $( window ).scrollTop( 0 ); + win.scrollTop( 0 ); $( "#elx" ).position({ my: "right bottom", @@ -150,23 +163,23 @@ test( "of", function() { collision: "none" }); deepEqual( $( "#elx" ).offset(), { - top: $( window ).height() - 10, - left: $( window ).width() - 10 + top: win.height() - 10, + left: win.width() - 10 }, "window" ); $( "#elx" ).position({ my: "right bottom", at: "right bottom", - of: $( window ), + of: win, collision: "none" }); deepEqual( $( "#elx" ).offset(), { - top: $( window ).height() - 10, - left: $( window ).width() - 10 + top: win.height() - 10, + left: win.width() - 10 }, "window as jQuery object" ); if ( scrollTopSupport() ) { - $( window ).scrollTop( 500 ).scrollLeft( 200 ); + win.scrollTop( 500 ).scrollLeft( 200 ); $( "#elx" ).position({ my: "right bottom", at: "right bottom", @@ -174,13 +187,13 @@ test( "of", function() { collision: "none" }); deepEqual( $( "#elx" ).offset(), { - top: $( window ).height() + 500 - 10, - left: $( window ).width() + 200 - 10 + top: win.height() + 500 - 10, + left: win.width() + 200 - 10 }, "window, scrolled" ); - $( window ).scrollTop( 0 ).scrollLeft( 0 ); + win.scrollTop( 0 ).scrollLeft( 0 ); } - var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } ); + event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } ); $( "#elx" ).position({ my: "left top", at: "left top", @@ -206,6 +219,8 @@ test( "of", function() { }); test( "offsets", function() { + expect( 4 ); + $( "#elx" ).position({ my: "left top", at: "left+10 bottom+10", @@ -272,7 +287,7 @@ function collisionTest( config, result, msg ) { var elem = $( "#elx" ).position( $.extend({ my: "left top", at: "right bottom", - of: window + of: "#parent" }, config ) ); deepEqual( elem.offset(), result, msg ); } @@ -284,239 +299,279 @@ function collisionTest2( config, result, msg ) { }, config ), result, msg ); } -test( "collision: fit, no offset", function() { - collisionTest({ - collision: "fit" - }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" ); +test( "collision: fit, no collision", function() { + expect( 2 ); - collisionTest2({ + collisionTest({ collision: "fit" - }, { top: 0, left: 0 }, "left top" ); -}); + }, { + top: 10, + left: 10 + }, "no offset" ); -test( "collision: fit, with offset", function() { collisionTest({ - collision: "fit", + collition: "fit", at: "right+2 bottom+3" - }, { top: $(window).height() - 10, left: $(window).width() - 10 }, "right bottom"); + }, { + top: 13, + left: 12 + }, "with offset" ); +}); + +test( "collision: fit, collision", function() { + expect( 2 + (scrollTopSupport() ? 1 : 0) ); collisionTest2({ - collision: "fit", - at: "left+2 top+3" - }, { top: 0, left: 0 }, "left top, positive offset" ); + collision: "fit" + }, { + top: 0, + left: 0 + }, "no offset" ); collisionTest2({ collision: "fit", - at: "left-2 top-3" - }, { top: 0, left: 0 }, "left top, negative offset" ); -}); + at: "left+2 top+3" + }, { + top: 0, + left: 0 + }, "with offset" ); -test( "collision: fit, window scrolled", function() { if ( scrollTopSupport() ) { - var win = $( window ); win.scrollTop( 300 ).scrollLeft( 200 ); - collisionTest({ - collision: "fit", - at: "left-100 top-100" - }, { top: 300, left: 200 }, "top left" ); - collisionTest2({ - collision: "fit", - at: "right+100 bottom+100" - }, { top: 300 + win.height() - 10, left: 200 + win.width() - 10 }, "right bottom" ); + collision: "fit" + }, { + top: 300, + left: 200 + }, "window scrolled" ); win.scrollTop( 0 ).scrollLeft( 0 ); } }); -test( "collision: flip, no offset", function() { - collisionTest({ - collision: "flip" - }, { top: $( window ).height(), left: $( window ).width() }, "left top" ); +test( "collision: flip, no collision", function() { + expect( 2 ); - collisionTest2({ + collisionTest({ collision: "flip" - }, { top: -10, left: -10 }, "right bottom" ); -}); + }, { + top: 10, + left: 10 + }, "no offset" ); -test( "collision: flip, with offset", function() { collisionTest({ collision: "flip", at: "right+2 bottom+3" - }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "left top, with offset added" ); + }, { + top: 13, + left: 12 + }, "with offset" ); +}); + +test( "collision: flip, collision", function() { + expect( 2 ); collisionTest2({ - collision: "flip", - at: "left+2 top+3" - }, { top: -7, left: -8 }, "bottom, positive offset" ); + collision: "flip" + }, { + top: 10, + left: 10 + }, "no offset" ); collisionTest2({ collision: "flip", - at: "left-2 top-3" - }, { top: -13, left: -12 }, "right bottom, negative offset" ); + at: "left+2 top+3" + }, { + top: 7, + left: 8 + }, "with offset" ); }); -test( "collision: none, no offset", function() { - collisionTest({ - collision: "none" - }, { top: $( window ).height(), left: $( window ).width() }, "left top" ); +test( "collision: flipfit, no collision", function() { + expect( 2 ); - collisionTest2({ - collision: "none" - }, { top: -10, left: -10 }, "moved to the right bottom" ); -}); + collisionTest({ + collision: "flipfit" + }, { + top: 10, + left: 10 + }, "no offset" ); -test( "collision: none, with offset", function() { collisionTest({ - collision: "none", + collision: "flipfit", at: "right+2 bottom+3" - }, { top: $( window ).height() + 3, left: $( window ).width() + 2 }, "right bottom, with offset added" ); + }, { + top: 13, + left: 12 + }, "with offset" ); +}); + +test( "collision: flipfit, collision", function() { + expect( 2 ); collisionTest2({ - collision: "none", - at: "left+2 top+3" - }, { top: -7, left: -8 }, "left top, positive offset" ); + collision: "flipfit" + }, { + top: 10, + left: 10 + }, "no offset" ); collisionTest2({ - collision: "none", - at: "left-2 top-3" - }, { top: -13, left: -12 }, "left top, negative offset" ); + collision: "flipfit", + at: "left+2 top+3" + }, { + top: 7, + left: 8 + }, "with offset" ); }); -test( "collision: fit, with margin", function() { - $( "#elx" ).css( "margin", 10 ); +test( "collision: none, no collision", function() { + expect( 2 ); collisionTest({ - collision: "fit" - }, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" ); + collision: "none" + }, { + top: 10, + left: 10 + }, "no offset" ); - collisionTest2({ - collision: "fit" - }, { top: 10, left: 10 }, "left top" ); + collisionTest({ + collision: "none", + at: "right+2 bottom+3" + }, { + top: 13, + left: 12 + }, "with offset" ); +}); - $( "#elx" ).css({ - "margin-left": 5, - "margin-top": 5 - }); +test( "collision: none, collision", function() { + expect( 2 ); - collisionTest({ - collision: "fit" - }, { top: $( window ).height() - 20, left: $( window ).width() - 20 }, "right bottom" ); + collisionTest2({ + collision: "none" + }, { + top: -6, + left: -6 + }, "no offset" ); collisionTest2({ - collision: "fit" - }, { top: 5, left: 5 }, "left top" ); + collision: "none", + at: "left+2 top+3" + }, { + top: -3, + left: -4 + }, "with offset" ); +}); + +test( "collision: fit, with margin", function() { + expect( 2 ); $( "#elx" ).css({ - "margin-right": 15, - "margin-bottom": 15 + marginTop: 6, + marginLeft: 4 }); collisionTest({ collision: "fit" - }, { top: $( window ).height() - 25, left: $( window ).width() - 25 }, "right bottom" ); + }, { + top: 10, + left: 10 + }, "right bottom" ); collisionTest2({ collision: "fit" - }, { top: 5, left: 5 }, "left top" ); + }, { + top: 6, + left: 4 + }, "left top" ); }); test( "collision: flip, with margin", function() { - $( "#elx" ).css( "margin", 10 ); - - collisionTest({ - collision: "flip", - at: "left top" - }, { top: 0, left: 0 }, "left top" ); - - collisionTest2({ - collision: "flip", - at: "right bottom" - }, { top: $( window ).height() - 10, left: $( window ).width() - 10 }, "right bottom" ); -}); - -test( "addClass: flipped left", function() { - var elem = $( "#elx" ).position( { - my: "left center", - of: window, - collision: "flip", - at: "right center" - }); + expect( 3 ); - deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' ); - - elem.position({ - my: "right center", - of: window, - collision: "flip", - at: "left center" + $( "#elx" ).css({ + marginTop: 6, + marginLeft: 4 }); - deepEqual( 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" - }); + collisionTest({ + collision: "flip" + }, { + top: 10, + left: 10 + }, "left top" ); - deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' ); + collisionTest2({ + collision: "flip" + }, { + top: 10, + left: 10 + }, "right bottom" ); - elem.position( { - my: "left bottom", - of: window, + collisionTest2({ collision: "flip", - at: "right top" - }); - - deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' ); + my: "left top" + }, { + top: 0, + left: 4 + }, "right bottom" ); }); -test( "addClass: flipped right", function() { - var elem = $( "#elx" ).position( { - my: "right center", - of: window, - collision: "flip", - at: "left center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' ); - - elem.position( { - my: "left center", - of: window, - collision: "flip", - at: "right center" - }); +test( "within", function() { + expect( 6 ); - deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' ); + collisionTest({ + within: "#within", + collision: "fit" + }, { + top: 4, + left: 2 + }, "fit - right bottom" ); -}); + collisionTest2({ + within: "#within", + collision: "fit" + }, { + top: 2, + left: 0 + }, "fit - left top" ); -test( "addClass: flipped bottom", function() { - var elem = $( "#elx" ).position( { - my: "left bottom", - of: window, - collision: "flip", - at: "right top" - }); + collisionTest({ + within: "#within", + collision: "flip" + }, { + top: 10, + left: -6 + }, "flip - right bottom" ); - deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' ); + collisionTest2({ + within: "#within", + collision: "flip" + }, { + top: 10, + left: -6 + }, "flip - left top" ); - elem.position( { - my: "left top", - of: window, - collision: "flip", - at: "right bottom" - }); + collisionTest({ + within: "#within", + collision: "flipfit" + }, { + top: 4, + left: 0 + }, "flipfit - right bottom" ); - deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' ); + collisionTest2({ + within: "#within", + collision: "flipfit" + }, { + top: 4, + left: 0 + }, "flipfit - left top" ); }); test( "fractions", function() { + expect( 1 ); + $( "#fractions-element" ).position({ my: "left top", at: "left top", @@ -527,6 +582,8 @@ test( "fractions", function() { }); test( "bug #5280: consistent results (avoid fractional values)", function() { + expect( 1 ); + var wrapper = $( "#bug-5280" ), elem = wrapper.children(), offset1 = elem.position({ diff --git a/tests/unit/position/position_core_within.js b/tests/unit/position/position_core_within.js deleted file mode 100644 index 042e881eb..000000000 --- a/tests/unit/position/position_core_within.js +++ /dev/null @@ -1,540 +0,0 @@ -(function( $ ) { - -function scrollTopSupport() { - $( window ).scrollTop( 1 ); - return $( window ).scrollTop() === 1; -} - -module( "position - within", { - setup: function(){ - $("#within-container").css({"width": "70px", "height": "70px", "top": "20px", "left": "20px", "position": "relative"}).show(); - } -}); - -var addTop = -20, - addLeft = -20; - -$.fn.addOffsets = function() { - var elOffset = this.offset(), - offset = $("#within-container").offset(); - - elOffset.top -= offset.top; - elOffset.left -= offset.left; - - return {top: elOffset.top - offset.top, left: elOffset.left - offset.left }; -}; - -test( "my, at, of", function() { - var within = $("#within-container"); - - $( "#elx" ).position({ - my: "left top", - at: "left top", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "left top, left top" ); - - $( "#elx" ).position({ - my: "left top", - at: "left bottom", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "left top, left bottom" ); - - $( "#elx" ).position({ - my: "left", - at: "bottom", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 55, left: addLeft + 50 }, "left, bottom" ); - - $( "#elx" ).position({ - my: "left foo", - at: "bar baz", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 45, left: addLeft +50 }, "left foo, bar baz" ); -}); - -test( "multiple elements", function() { - var elements = $( "#el1, #el2" ), - result = elements.position({ - my: "left top", - at: "left bottom", - of: "#parent", - collision: "none", - within: $("#within-container") - }), - expected = { top: addTop + 10, left: addLeft + 4 }; - - deepEqual( result, elements ); - elements.each(function() { - deepEqual( $( this ).addOffsets(), expected ); - }); -}); - -test( "positions", function() { - var definitions = [], - offsets = { - left: 0, - center: 3, - right: 6, - top: 0, - bottom: 6 - }, - start = { left: 4, top: 4 }, - el = $( "#el1" ); - $.each( [ 0, 1 ], function( my ) { - $.each( [ "top", "center", "bottom" ], function( vindex, vertical ) { - $.each( [ "left", "center", "right" ], function( hindex, horizontal ) { - definitions.push({ - my: my ? horizontal + " " + vertical : "left top", - at: !my ? horizontal + " " + vertical : "left top", - result: { - top: addTop + (my ? start.top - offsets[ vertical ] : start.top + offsets[ vertical ]), - left: addLeft + (my ? start.left - offsets[ horizontal ] : start.left + offsets[ horizontal ]) - } - }); - }); - }); - }); - $.each( definitions, function( index, definition ) { - el.position({ - my: definition.my, - at: definition.at, - of: "#parent", - collision: "none", - within: $("#within-container") - }); - deepEqual( el.addOffsets(), definition.result, - "Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) ); - }); -}); - -test( "of", function() { - var event, - within = $( "#within-container" ); - - $( "#elx" ).position({ - my: "left top", - at: "left top", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "selector" ); - - $( "#elx" ).position({ - my: "left top", - at: "left bottom", - of: $( "#parentx"), - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "jQuery object" ); - - $( "#elx" ).position({ - my: "left top", - at: "left top", - of: $( "#parentx" )[ 0 ], - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "DOM element" ); - - event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } ); - $( "#elx" ).position({ - my: "left top", - at: "left top", - of: event, - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).offset(), { - top: 300, - left: 200 - }, "event - left top, left top" ); - - event = $.extend( $.Event( "someEvent" ), { pageX: 400, pageY: 600 } ); - $( "#elx" ).position({ - my: "left top", - at: "right bottom", - of: event, - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).offset(), { - top: 600, - left: 400 - }, "event - left top, right bottom" ); -}); - -test( "within:offsets", function() { - var within = $("#within-container"); - - $( "#elx" ).position({ - my: "left top", - at: "left+10 bottom+10", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 70, left: addLeft + 50 }, "offsets in at" ); - - $( "#elx" ).position({ - my: "left+10 top-10", - at: "left bottom", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 50, left: addLeft + 50 }, "offsets in my" ); - - $( "#elx" ).position({ - my: "left top", - at: "left+50% bottom-10%", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 58, left: addLeft + 50 }, "percentage offsets in at" ); - - $( "#elx" ).position({ - my: "left-30% top+50%", - at: "left bottom", - of: "#parentx", - collision: "none", - within: within - }); - deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 65, left: addLeft + 37 }, "percentage offsets in my" ); -}); - -test( "using", function() { - expect( 6 ); - - var within = $( "#within-container" ), - count = 0, - elems = $( "#el1, #el2" ), - expectedPosition = { top: addTop + 40, left: addLeft + 40 }, - originalPosition = elems.position({ - my: "right bottom", - at: "right bottom", - of: "#parentx", - collision: "none", - within: within - }).addOffsets(); - - elems.position({ - my: "left top", - at: "left top", - of: "#parentx", - using: function( position ) { - position.top -= within.offset().top; - position.left -= within.offset().left; - deepEqual( this, elems[ count ], "correct context for call #" + count ); - deepEqual( position, expectedPosition, "correct position for call #" + count ); - count++; - }, - within: within - }); - - elems.each(function() { - deepEqual( $( this ).addOffsets(), originalPosition, "elements not moved" ); - }); -}); - -function collisionTest( config, result, msg ) { - var within = $( "#within-container" ), - elem = $( "#elx" ).position( $.extend({ - my: "left top", - at: "right bottom", - of: "#parentx", - within: within - }, config ) ); - - deepEqual( elem.addOffsets(), result, msg ); -} - -function collisionTest2( config, result, msg ) { - collisionTest( $.extend({ - my: "right bottom", - at: "left top" - }, config ), result, msg ); -} - -test( "collision: fit, no offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "fit" - }, { top: addTop + of.position().top + of.height() - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).height, left: addLeft + of.position().left + of.width() - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).width }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); -}); - - -test( "collision: fit, with offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "fit", - at: "right+2 bottom+3" - }, { top: addTop + of.position().top + of.height() - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).height, left: addLeft + of.position().left + of.width() - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).width }, "right bottom"); - - collisionTest2({ - collision: "fit", - at: "left+2 top+3" - }, { top: addTop + of.position().top - 7, left: addLeft + of.position().left - 8 }, "left top, positive offset" ); - - collisionTest2({ - collision: "fit", - at: "left-2 top-3" - }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "left top, negative offset" ); -}); - -test( "collision: none, within scrolled", function() { - if ( scrollTopSupport() ) { - var within = $("#within-container").css({"width": "1000px", "height": "800px", "overflow": "auto"}), - of = $("#parentx"); - within.scrollTop( 300 ).scrollLeft( 150 ); - - collisionTest({ - collision: "none", - at: "left-100 top-100" - }, { top: of.offset().top + addTop - 100 - of.height(), left: of.offset().left + addLeft - 100 - of.width() }, "top left" ); - collisionTest2({ - collision: "none", - at: "right+100 bottom+100" - }, { top: of.offset().top + addTop + 100 - 10, left: of.offset().left + addLeft + 100 - 10 }, "right bottom" ); - within.scrollTop( 0 ).scrollLeft( 0 ); - } -}); - -test( "collision: flip, no offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "flip" - }, { top: addTop + of.position().top + of.height(), left: addLeft + of.position().left + of.width() }, "left top" ); - - collisionTest2({ - collision: "flip" - }, { top: addTop + of.position().top - 10, left: addTop + of.position().top - 10 }, "right bottom" ); -}); - -test( "collision: flip, with offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "flip", - at: "right+2 bottom+3" - }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "left top, with offset added" ); - - collisionTest2({ - collision: "flip", - at: "left+2 top+3" - }, { top: addTop + of.position().top - 10 + 3, left: addLeft + of.position().left - 10 + 2 }, "right bottom, positive offset" ); - - collisionTest2({ - collision: "flip", - at: "left-2 top-3" - }, { top: addTop + of.position().top - 13, left: addLeft + of.position().left - 12 }, "right bottom, negative offset" ); -}); - -test( "collision: none, no offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "none" - }, { top: addTop + of.position().top + of.height(), left: addLeft + of.position().left + of.width() }, "left top" ); - - collisionTest2({ - collision: "none" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "right bottom" ); -}); - -test( "collision: none, with offset", function() { - var within = $("#within-container"), - of = $("#parentx"); - - collisionTest({ - collision: "none", - at: "right+2 bottom+3" - }, { top: addTop + of.position().top + of.height() + 3, left: addLeft + of.position().left + of.width() + 2 }, "right bottom, with offset added" ); - - collisionTest2({ - collision: "none", - at: "left+2 top+3" - }, { top: addTop + of.position().top - 7, left: addTop + of.position().top - 8 }, "left top, positive offset" ); - - collisionTest2({ - collision: "none", - at: "left-2 top-3" - }, { top: addTop + of.position().top - 13, left: addTop + of.position().top - 12 }, "left top, negative offset" ); -}); - -test( "collision: fit, with margin", function() { - var within = $("#within-container"), - of = $("#parentx"); - - $( "#elx" ).css( "margin", 10 ); - - collisionTest({ - collision: "fit" - }, { top: addTop + of.position().top + of.height() - 10 - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).height, left: addLeft + of.position().left + of.width() - 10 - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).width }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); - - $( "#elx" ).css({ - "margin-left": 5, - "margin-top": 5 - }); - - collisionTest({ - collision: "fit" - }, { top: addTop + of.position().top + of.height() - 10 - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).height, left: addLeft + of.position().left + of.width() - 10 - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).width }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); - - $( "#elx" ).css({ - "margin-right": 15, - "margin-bottom": 15 - }); - - collisionTest({ - collision: "fit" - }, { top: addTop + of.position().top + of.height() - 15 - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).height, left: addLeft + of.position().left + of.width() - 15 - $.position.getScrollInfo( $.position.getWithinInfo( within ) ).width }, "right bottom" ); - - collisionTest2({ - collision: "fit" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); -}); - -test( "collision: flip, with margin", function() { - var within = $("#within-container"), - of = $("#parentx"); - - $( "#elx" ).css( "margin", 10 ); - - collisionTest({ - collision: "flip" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "left top" ); - - collisionTest2({ - collision: "flip" - }, { top: addTop + of.position().top - 10, left: addLeft + of.position().left - 10 }, "right bottom" ); - - $( "#elx" ).css( "margin", 0 ); -}); - -test( "addClass: flipped left", function() { - var within = $("#within-container"), - elem = $( "#elx" ).position( { - my: "left center", - of: within[0], - within: within, - collision: "flip", - at: "right center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' ); - - elem.position({ - my: "right center", - of: within[0], - within: within, - collision: "flip", - at: "left center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' ); -}); - -test( "addClass: flipped top", function() { - var within = $("#within-container"), - elem = $( "#elx" ).position( { - my: "left top", - of: within[0], - within: within, - collision: "flip", - at: "right bottom" - }); - - deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' ); - - elem.position( { - my: "left bottom", - of: within[0], - within: within, - collision: "flip", - at: "right top" - }); - - deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' ); -}); - -test( "addClass: flipped right", function() { - var within = $("#within-container"), - elem = $( "#elx" ).position( { - my: "right center", - of: within[0], - within: within, - collision: "flip", - at: "left center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' ); - - elem.position( { - my: "left center", - of: within[0], - within: within, - collision: "flip", - at: "right center" - }); - - deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' ); - -}); - -test( "addClass: flipped bottom", function() { - var within = $("#within-container"), - elem = $( "#elx" ).position( { - my: "left bottom", - of: window, - collision: "flip", - at: "right top" - }); - - deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' ); - - elem.position( { - my: "left top", - of: window, - collision: "flip", - at: "right bottom" - }); - - deepEqual( 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 ee9be189d..8794812a8 100644 --- a/tests/unit/position/position_deprecated.html +++ b/tests/unit/position/position_deprecated.html @@ -5,17 +5,15 @@ <title>jQuery UI Position Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> - <script> - loadResources({ - js: [ "ui/jquery.ui.position.js" ] - }); - </script> - <link rel="stylesheet" href="../../../external/qunit.css"> <script src="../../../external/qunit.js"></script> <script src="../../jquery.simulate.js"></script> <script src="../testsuite.js"></script> + <script> + TestHelpers.loadResources({ + js: [ "ui/jquery.ui.position.js" ] + }); + </script> <script src="position_core.js"></script> <script src="position_deprecated.js"></script> @@ -35,33 +33,26 @@ elements smaller than 10px have a line-height set on them to avoid a bug in IE6 .height() returns the greater of the height and line-height --> -<div id="qunit-fixture" style="top: 0; left: 0;"> +<div id="qunit-fixture" style="top: 0; left: 0; z-index:1"> <div id="el1" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> <div id="el2" style="position: absolute; width: 6px; height: 6px; line-height: 6px;"></div> <div id="parent" style="position: absolute; width: 6px; height: 6px; top: 4px; left: 4px; line-height: 6px;"></div> -</div> - -<div style="position: absolute; top: 0px; left: 0px"> - <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div> -</div> + <div id="within" style="position: absolute; width: 12px; height: 12px; top: 2px; left: 0px;"></div> -<div style="position: absolute; top: 200px; left: 100px;"> - <div id="el-offset-100-200" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div style="position: absolute; top: 100px; left: 50px;"> - <div id="el-two-offset-150-300" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> - <div id="el-fixed" style="position: fixed; top: 200px; left: 200px;"></div> + <div style="position: absolute; top: 0px; left: 0px"> + <div id="elx" style="position: absolute; width: 10px; height: 10px; line-height: 10px;"></div> + <div id="parentx" style="position: absolute; width: 20px; height: 20px; top: 40px; left: 40px;"></div> </div> -</div> -<div style="position: absolute; height: 5000px; width: 5000px;"></div> + <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> + <div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;"> + <div id="fractions-element"></div> + </div> -<div id="fractions-parent" style="position: absolute; left: 10.7432222px; top: 10.532325px; height: 30px; width: 201px;"> - <div id="fractions-element"></div> + <div id="bug-5280" style="height: 30px; width: 201px;"> + <div style="width: 50px; height: 10px;"></div> + </div> </div> </body> diff --git a/tests/unit/progressbar/all.html b/tests/unit/progressbar/all.html index eefb9c135..16b9e0ace 100644 --- a/tests/unit/progressbar/all.html +++ b/tests/unit/progressbar/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/progressbar/progressbar.html b/tests/unit/progressbar/progressbar.html index 8b55f5a89..70a4abe56 100644 --- a/tests/unit/progressbar/progressbar.html +++ b/tests/unit/progressbar/progressbar.html @@ -5,9 +5,12 @@ <title>jQuery UI Progressbar Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.progressbar" ], js: [ "ui/jquery.ui.core.js", @@ -17,13 +20,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="progressbar_common.js"></script> <script src="progressbar_core.js"></script> - <script src="progressbar_defaults.js"></script> <script src="progressbar_events.js"></script> <script src="progressbar_methods.js"></script> <script src="progressbar_options.js"></script> diff --git a/tests/unit/progressbar/progressbar_defaults.js b/tests/unit/progressbar/progressbar_common.js index 2f97a78bb..2f97a78bb 100644 --- a/tests/unit/progressbar/progressbar_defaults.js +++ b/tests/unit/progressbar/progressbar_common.js diff --git a/tests/unit/qunit-composite.css b/tests/unit/qunit-composite.css new file mode 100644 index 000000000..df47362db --- /dev/null +++ b/tests/unit/qunit-composite.css @@ -0,0 +1,13 @@ +iframe.qunit-subsuite{ + position: fixed; + bottom: 0; + left: 0; + + margin: 0; + padding: 0; + border-width: 1px 0 0; + height: 45%; + width: 100%; + + background: #fff; +}
\ No newline at end of file diff --git a/tests/unit/qunit-composite.js b/tests/unit/qunit-composite.js new file mode 100644 index 000000000..89c47eb29 --- /dev/null +++ b/tests/unit/qunit-composite.js @@ -0,0 +1,102 @@ +(function( QUnit ) { + +QUnit.extend( QUnit, { + testSuites: function( suites ) { + QUnit.begin(function() { + QUnit.initIframe(); + }); + + for ( var i = 0; i < suites.length; i++ ) { + QUnit.runSuite( suites[i] ); + } + + QUnit.done(function() { + this.iframe.style.display = "none"; + }); + }, + + runSuite: function( suite ) { + asyncTest( suite, function() { + QUnit.iframe.setAttribute( "src", suite ); + }); + }, + + initIframe: function() { + var body = document.body, + iframe = this.iframe = document.createElement( "iframe" ), + iframeWin; + + iframe.className = "qunit-subsuite"; + body.appendChild( iframe ); + + function onIframeLoad() { + var module, test, + count = 0; + + + iframeWin.QUnit.moduleStart(function( data ) { + // capture module name for messages + module = data.name; + }); + + iframeWin.QUnit.testStart(function( data ) { + // capture test name for messages + test = data.name; + }); + iframeWin.QUnit.testDone(function() { + test = null; + }); + + iframeWin.QUnit.log(function( data ) { + if (test === null) { + return; + } + // 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 ); + }); + + iframeWin.QUnit.done(function() { + // start the wrapper test from the main page + start(); + }); + } + QUnit.addEvent( iframe, "load", onIframeLoad ); + + iframeWin = iframe.contentWindow; + } +}); + +QUnit.testStart(function( data ) { + // update the test status to show which test suite is running + QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br> "; +}); + +QUnit.testDone(function() { + var i, + current = QUnit.id( this.config.current.id ), + children = current.children, + src = this.iframe.src; + + // undo the auto-expansion of failed tests + for ( i = 0; i < children.length; i++ ) { + if ( children[i].nodeName === "OL" ) { + children[i].style.display = "none"; + } + } + + QUnit.addEvent(current, "dblclick", function( e ) { + var target = e && e.target ? e.target : window.event.srcElement; + if ( target.nodeName.toLowerCase() === "span" || target.nodeName.toLowerCase() === "b" ) { + target = target.parentNode; + } + if ( window.location && target.nodeName.toLowerCase() === "strong" ) { + window.location = src; + } + }); + + current.getElementsByTagName('a')[0].href = src; +}); + +}( QUnit ) ); diff --git a/tests/unit/resizable/all.html b/tests/unit/resizable/all.html index 1c6811282..bef29ff6e 100644 --- a/tests/unit/resizable/all.html +++ b/tests/unit/resizable/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/resizable/resizable.html b/tests/unit/resizable/resizable.html index 4e886d2fd..9baa67493 100644 --- a/tests/unit/resizable/resizable.html +++ b/tests/unit/resizable/resizable.html @@ -5,9 +5,12 @@ <title>jQuery UI Resizable Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.resizable" ], js: [ "ui/jquery.ui.core.js", @@ -18,13 +21,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="resizable_common.js"></script> <script src="resizable_core.js"></script> - <script src="resizable_defaults.js"></script> <script src="resizable_events.js"></script> <script src="resizable_methods.js"></script> <script src="resizable_options.js"></script> diff --git a/tests/unit/resizable/resizable_defaults.js b/tests/unit/resizable/resizable_common.js index c46e10781..617cdd2ad 100644 --- a/tests/unit/resizable/resizable_defaults.js +++ b/tests/unit/resizable/resizable_common.js @@ -19,6 +19,9 @@ TestHelpers.commonWidgetTests('resizable', { maxWidth: null, minHeight: 10, minWidth: 10, - zIndex: 1000 + zIndex: 1000, + + // callbacks + create: null } }); diff --git a/tests/unit/resizable/resizable_events.js b/tests/unit/resizable/resizable_events.js index e8041f064..52d55731c 100644 --- a/tests/unit/resizable/resizable_events.js +++ b/tests/unit/resizable/resizable_events.js @@ -5,16 +5,4 @@ module("resizable: events"); -test("start", function() { - ok(false, "missing test - untested code is broken code."); -}); - -test("resize", function() { - ok(false, "missing test - untested code is broken code."); -}); - -test("stop", function() { - ok(false, "missing test - untested code is broken code."); -}); - })(jQuery); diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js index 2b4c4256c..87859acf7 100644 --- a/tests/unit/resizable/resizable_methods.js +++ b/tests/unit/resizable/resizable_methods.js @@ -5,60 +5,5 @@ module("resizable: methods"); -test("init", function() { - expect(6); - - $("<div></div>").appendTo('body').resizable().remove(); - ok(true, '.resizable() called on element'); - - $([]).resizable().remove(); - ok(true, '.resizable() called on empty collection'); - - $('<div></div>').resizable().remove(); - ok(true, '.resizable() called on disconnected DOMElement'); - - $('<div></div>').resizable().resizable("foo").remove(); - ok(true, 'arbitrary method called after init'); - - el = $('<div></div>').resizable(); - var foo = el.resizable("option", "foo"); - el.remove(); - ok(true, 'arbitrary option getter after init'); - - $('<div></div>').resizable().resizable("option", "foo", "bar").remove(); - ok(true, 'arbitrary option setter after init'); -}); - -test("destroy", function() { - $("<div></div>").appendTo('body').resizable().resizable("destroy").remove(); - ok(true, '.resizable("destroy") called on element'); - - $([]).resizable().resizable("destroy").remove(); - ok(true, '.resizable("destroy") called on empty collection'); - - $('<div></div>').resizable().resizable("destroy").remove(); - ok(true, '.resizable("destroy") called on disconnected DOMElement'); - - $('<div></div>').resizable().resizable("destroy").resizable("foo").remove(); - ok(true, 'arbitrary method called after destroy'); - - var expected = $('<div></div>').resizable(), - actual = expected.resizable('destroy'); - equal(actual, expected, 'destroy is chainable'); -}); - -test("enable", function() { - var expected = $('<div></div>').resizable(), - actual = expected.resizable('enable'); - equal(actual, expected, 'enable is chainable'); - ok(false, "missing test - untested code is broken code."); -}); - -test("disable", function() { - var expected = $('<div></div>').resizable(), - actual = expected.resizable('disable'); - equal(actual, expected, 'disable is chainable'); - ok(false, "missing test - untested code is broken code."); -}); })(jQuery); diff --git a/tests/unit/resizable/resizable_options.js b/tests/unit/resizable/resizable_options.js index 275639ca1..e10a55a31 100644 --- a/tests/unit/resizable/resizable_options.js +++ b/tests/unit/resizable/resizable_options.js @@ -189,10 +189,10 @@ test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1 test("zIndex, applied to all handles", function() { expect(8); - + var target = $('<div></div>').resizable({ handles: 'all', zIndex: 100 }); target.children( '.ui-resizable-handle' ).each( function( index, handle ) { - equals( $( handle ).css( 'zIndex' ), 100, 'compare zIndex' ); + equal( $( handle ).css( 'zIndex' ), 100, 'compare zIndex' ); }); }); diff --git a/tests/unit/selectable/all.html b/tests/unit/selectable/all.html index bfebf46c2..51778e771 100644 --- a/tests/unit/selectable/all.html +++ b/tests/unit/selectable/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/selectable/selectable.html b/tests/unit/selectable/selectable.html index 4f70e8dd4..7b0ca6ffe 100644 --- a/tests/unit/selectable/selectable.html +++ b/tests/unit/selectable/selectable.html @@ -5,9 +5,12 @@ <title>jQuery UI Selectable Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.selectable" ], js: [ "ui/jquery.ui.core.js", @@ -18,13 +21,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="selectable_common.js"></script> <script src="selectable_core.js"></script> - <script src="selectable_defaults.js"></script> <script src="selectable_events.js"></script> <script src="selectable_methods.js"></script> <script src="selectable_options.js"></script> diff --git a/tests/unit/selectable/selectable_defaults.js b/tests/unit/selectable/selectable_common.js index 27714d0ae..27714d0ae 100644 --- a/tests/unit/selectable/selectable_defaults.js +++ b/tests/unit/selectable/selectable_common.js diff --git a/tests/unit/slider/all.html b/tests/unit/slider/all.html index 5aac26ced..bfadc0380 100644 --- a/tests/unit/slider/all.html +++ b/tests/unit/slider/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/slider/slider.html b/tests/unit/slider/slider.html index 60d124b7a..3aec78b4b 100644 --- a/tests/unit/slider/slider.html +++ b/tests/unit/slider/slider.html @@ -5,9 +5,12 @@ <title>jQuery UI Slider Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.slider" ], js: [ "ui/jquery.ui.core.js", @@ -18,13 +21,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="slider_common.js"></script> <script src="slider_core.js"></script> - <script src="slider_defaults.js"></script> <script src="slider_events.js"></script> <script src="slider_methods.js"></script> <script src="slider_options.js"></script> diff --git a/tests/unit/slider/slider_defaults.js b/tests/unit/slider/slider_common.js index 8a0b347f3..8a0b347f3 100644 --- a/tests/unit/slider/slider_defaults.js +++ b/tests/unit/slider/slider_common.js diff --git a/tests/unit/sortable/all.html b/tests/unit/sortable/all.html index 89e239250..f9d63d62e 100644 --- a/tests/unit/sortable/all.html +++ b/tests/unit/sortable/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html index a20eb7109..c84c62197 100644 --- a/tests/unit/sortable/sortable.html +++ b/tests/unit/sortable/sortable.html @@ -5,9 +5,12 @@ <title>jQuery UI Sortable Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.sortable" ], js: [ "ui/jquery.ui.core.js", @@ -18,13 +21,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - + <script src="sortable_common.js"></script> <script src="sortable_core.js"></script> - <script src="sortable_defaults.js"></script> <script src="sortable_events.js"></script> <script src="sortable_methods.js"></script> <script src="sortable_options.js"></script> diff --git a/tests/unit/sortable/sortable_defaults.js b/tests/unit/sortable/sortable_common.js index b5fc05a5d..b5fc05a5d 100644 --- a/tests/unit/sortable/sortable_defaults.js +++ b/tests/unit/sortable/sortable_common.js diff --git a/tests/unit/spinner/all.html b/tests/unit/spinner/all.html index e41e088c4..72a2dd77a 100644 --- a/tests/unit/spinner/all.html +++ b/tests/unit/spinner/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/spinner/spinner.html b/tests/unit/spinner/spinner.html index 0c01a5f48..b7f4a532a 100644 --- a/tests/unit/spinner/spinner.html +++ b/tests/unit/spinner/spinner.html @@ -3,14 +3,17 @@ <head> <meta charset="utf-8"> <title>jQuery UI Spinner Test Suite</title> - + <script src="../../jquery.js"></script> <script src="../../../external/jquery.mousewheel-3.0.4.js"></script> <script src="../../../external/globalize.js"></script> <script src="../../../external/globalize.culture.ja-JP.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.button", "ui.spinner" ], js: [ "ui/jquery.ui.core.js", @@ -21,14 +24,9 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script src="spinner_test_helpers.js"></script> + <script src="spinner_common.js"></script> <script src="spinner_core.js"></script> - <script src="spinner_defaults.js"></script> <script src="spinner_events.js"></script> <script src="spinner_methods.js"></script> <script src="spinner_options.js"></script> diff --git a/tests/unit/spinner/spinner_defaults.js b/tests/unit/spinner/spinner_common.js index 4f05b1e63..4f05b1e63 100644 --- a/tests/unit/spinner/spinner_defaults.js +++ b/tests/unit/spinner/spinner_common.js diff --git a/tests/unit/subsuiteRunner.css b/tests/unit/subsuiteRunner.css deleted file mode 100644 index bca30a75e..000000000 --- a/tests/unit/subsuiteRunner.css +++ /dev/null @@ -1,8 +0,0 @@ -iframe.qunit-subsuite { - margin: 0; - padding: 0; - border-width: 1px 0 0; - height: 600px; - width: 100%; - background: #fff; -}
\ No newline at end of file diff --git a/tests/unit/subsuiteRunner.js b/tests/unit/subsuiteRunner.js deleted file mode 100644 index 2d6de2de1..000000000 --- a/tests/unit/subsuiteRunner.js +++ /dev/null @@ -1,88 +0,0 @@ -(function( QUnit ) { - -var subsuiteFrame; - -QUnit.extend( QUnit, { - testSuites: function( suites ) { - function generateSuite( suite ) { - asyncTest( suite, function() { - QUnit.runSuite( suite ); - }); - } - - for ( var i = 0; i < suites.length; i++ ) { - generateSuite( suites[ i ] ); - } - - QUnit.done = function() { - subsuiteFrame.style.display = "none"; - }; - }, - - testStart: function( data ) { - // update the test status to show which test suite is running - QUnit.id( "qunit-testresult" ).innerHTML = "Running " + data.name + "...<br> "; - }, - - testDone: function() { - var current = QUnit.id( this.config.current.id ), - children = current.children, - i = 0, - length = children.length; - - // undo the auto-expansion of failed tests - for ( ; i < length; i++ ) { - if ( children[i].nodeName === "OL" ) { - children[i].style.display = "none"; - } - } - }, - - runSuite: function( suite ) { - var iframeWin, - body = document.getElementsByTagName( "body" )[0], - iframe = document.createElement( "iframe" ); - - subsuiteFrame = iframe; - iframe.className = "qunit-subsuite"; - body.appendChild( iframe ); - - function onIframeLoad() { - var module, test, - count = 0; - - QUnit.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() { - // start the wrapper test from the main page - start(); - } - }); - } - QUnit.addEvent( iframe, "load", onIframeLoad ); - - iframeWin = iframe.contentWindow; - iframe.setAttribute( "src", suite ); - - this.runSuite = function( suite ) { - iframe.setAttribute( "src", suite ); - }; - } -}); -}( QUnit ) ); diff --git a/tests/unit/tabs/all.html b/tests/unit/tabs/all.html index 1da3ecad2..41bf965f2 100644 --- a/tests/unit/tabs/all.html +++ b/tests/unit/tabs/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/tabs/tabs.html b/tests/unit/tabs/tabs.html index 7f60ad277..fc7bfeedf 100644 --- a/tests/unit/tabs/tabs.html +++ b/tests/unit/tabs/tabs.html @@ -8,9 +8,12 @@ <script> $.uiBackCompat = false; </script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.tabs" ], js: [ "ui/jquery.ui.core.js", @@ -20,13 +23,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script src="tabs_test_helpers.js"></script> - <script src="tabs_defaults.js"></script> + <script src="tabs_common.js"></script> <script src="tabs_core.js"></script> <script src="tabs_events.js"></script> <script src="tabs_methods.js"></script> diff --git a/tests/unit/tabs/tabs_defaults.js b/tests/unit/tabs/tabs_common.js index 7ffb05da4..7ffb05da4 100644 --- a/tests/unit/tabs/tabs_defaults.js +++ b/tests/unit/tabs/tabs_common.js diff --git a/tests/unit/tabs/tabs_defaults_deprecated.js b/tests/unit/tabs/tabs_common_deprecated.js index fdcff21b3..fdcff21b3 100644 --- a/tests/unit/tabs/tabs_defaults_deprecated.js +++ b/tests/unit/tabs/tabs_common_deprecated.js diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html index c22ec3369..0c7611c9d 100644 --- a/tests/unit/tabs/tabs_deprecated.html +++ b/tests/unit/tabs/tabs_deprecated.html @@ -6,9 +6,12 @@ <script src="../../jquery.js"></script> <script src="../../../external/jquery.cookie.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.tabs" ], js: [ "ui/jquery.ui.core.js", @@ -18,13 +21,8 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script src="tabs_test_helpers.js"></script> - <script src="tabs_defaults_deprecated.js"></script> + <script src="tabs_common_deprecated.js"></script> <script src="tabs_core.js"></script> <script src="tabs_events.js"></script> <script src="tabs_methods.js"></script> diff --git a/tests/unit/testsuite.js b/tests/unit/testsuite.js index a877e38af..7e505979c 100644 --- a/tests/unit/testsuite.js +++ b/tests/unit/testsuite.js @@ -1,7 +1,66 @@ -(function() { +(function( $ ) { window.TestHelpers = {}; +function includeStyle( url ) { + document.write( "<link rel='stylesheet' href='../../../" + url + "'>" ); +} + +function includeScript( url ) { + document.write( "<script src='../../../" + url + "'></script>" ); +} + +QUnit.config.urlConfig.push( "min" ); +TestHelpers.loadResources = QUnit.urlParams.min ? + function() { + // TODO: proper include with theme images + includeStyle( "dist/jquery-ui.min.css" ); + includeScript( "dist/jquery-ui.min.js" ); + } : + function( resources ) { + $.each( resources.css || [], function( i, resource ) { + includeStyle( "themes/base/jquery." + resource + ".css" ); + }); + $.each( resources.js || [], function( i, resource ) { + includeScript( resource ); + }); + }; + +QUnit.config.urlConfig.push( "nojshint" ); +function testJshint( widget ) { + if ( QUnit.urlParams.nojshint ) { + return; + } + + includeScript( "external/jshint.js" ); + asyncTest( "JSHint", function() { + expect( 1 ); + + $.when( + $.ajax({ + url: "../../../ui/.jshintrc", + dataType: "json" + }), + $.ajax({ + url: "../../../ui/jquery.ui." + widget + ".js", + dataType: "text" + }) + ).done(function( hintArgs, srcArgs ) { + var passed = JSHINT( srcArgs[ 0 ], hintArgs[ 0 ] ), + errors = $.map( JSHINT.errors, function( error ) { + return "[L" + error.line + ":C" + error.character + "] " + + error.reason + "\n" + error.evidence + "\n"; + }).join( "\n" ); + ok( passed, errors ); + start(); + }) + .fail(function() { + ok( false, "error loading source" ); + start(); + }); + }); +} + function testWidgetDefaults( widget, defaults ) { var pluginDefaults = $.ui[ widget ].prototype.options; @@ -24,17 +83,15 @@ function testWidgetDefaults( widget, defaults ) { }); } -var privateMethods = [ - "_createWidget", - "destroy", - "option", - "_trigger" -]; - function testWidgetOverrides( widget ) { if ( $.uiBackCompat === false ) { test( "$.widget overrides", function() { - $.each( privateMethods, function( i, method ) { + $.each([ + "_createWidget", + "destroy", + "option", + "_trigger" + ], function( i, method ) { strictEqual( $.ui[ widget ].prototype[ method ], $.Widget.prototype[ method ], "should not override " + method ); }); @@ -59,6 +116,7 @@ function testBasicUsage( widget ) { TestHelpers.commonWidgetTests = function( widget, settings ) { module( widget + ": common widget" ); + testJshint( widget ); testWidgetDefaults( widget, settings.defaults ); testWidgetOverrides( widget ); testBasicUsage( widget ); @@ -106,4 +164,4 @@ window.domEqual = function( selector, modifier, message ) { QUnit.push( QUnit.equiv(actual, expected), actual, expected, message ); }; -}()); +}( jQuery )); diff --git a/tests/unit/tooltip/all.html b/tests/unit/tooltip/all.html index deb628e2f..c1aa35acf 100644 --- a/tests/unit/tooltip/all.html +++ b/tests/unit/tooltip/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/tooltip/tooltip.html b/tests/unit/tooltip/tooltip.html index b5e8558e5..d20ba8578 100644 --- a/tests/unit/tooltip/tooltip.html +++ b/tests/unit/tooltip/tooltip.html @@ -5,9 +5,12 @@ <title>jQuery UI Tooltip Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core", "ui.tooltip" ], js: [ "ui/jquery.ui.core.js", @@ -18,12 +21,7 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - - <script src="tooltip_defaults.js"></script> + <script src="tooltip_common.js"></script> <script src="tooltip_core.js"></script> <script src="tooltip_events.js"></script> <script src="tooltip_methods.js"></script> diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_common.js index d12ee9519..d12ee9519 100644 --- a/tests/unit/tooltip/tooltip_defaults.js +++ b/tests/unit/tooltip/tooltip_common.js diff --git a/tests/unit/widget/all.html b/tests/unit/widget/all.html index cad4bdd72..e5b16c8d7 100644 --- a/tests/unit/widget/all.html +++ b/tests/unit/widget/all.html @@ -7,9 +7,9 @@ <script src="../../../jquery-1.7.2.js"></script> <link rel="stylesheet" href="../../../external/qunit.css"> - <link rel="stylesheet" href="../subsuiteRunner.css"> + <link rel="stylesheet" href="../qunit-composite.css"> <script src="../../../external/qunit.js"></script> - <script src="../subsuiteRunner.js"></script> + <script src="../qunit-composite.js"></script> <script src="../subsuite.js"></script> <script> diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html index 6f4caaa6c..15eaee6aa 100644 --- a/tests/unit/widget/widget.html +++ b/tests/unit/widget/widget.html @@ -5,9 +5,12 @@ <title>jQuery UI Widget Test Suite</title> <script src="../../jquery.js"></script> - <script src="../../resource_loader.js"></script> + <link rel="stylesheet" href="../../../external/qunit.css"> + <script src="../../../external/qunit.js"></script> + <script src="../../jquery.simulate.js"></script> + <script src="../testsuite.js"></script> <script> - loadResources({ + TestHelpers.loadResources({ css: [ "ui.core" ], js: [ "ui/jquery.ui.widget.js" @@ -15,11 +18,6 @@ }); </script> - <link rel="stylesheet" href="../../../external/qunit.css"> - <script src="../../../external/qunit.js"></script> - <script src="../../jquery.simulate.js"></script> - <script src="../testsuite.js"></script> - <script src="widget_core.js"></script> <script src="widget_extend.js"></script> <script src="widget_animation.js"></script> |