aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/accordion/accordion_events.js7
-rw-r--r--tests/unit/accordion/accordion_methods.js7
-rw-r--r--tests/unit/all.html2
-rw-r--r--tests/unit/autocomplete/autocomplete_core.js6
-rw-r--r--tests/unit/autocomplete/autocomplete_options.js11
-rw-r--r--tests/unit/button/button_options.js29
-rw-r--r--tests/unit/core/core.html11
-rw-r--r--tests/unit/core/core.js19
-rw-r--r--tests/unit/core/core_deprecated.html136
-rw-r--r--tests/unit/core/core_deprecated.js24
-rw-r--r--tests/unit/dialog/dialog_deprecated.html67
-rw-r--r--tests/unit/dialog/dialog_deprecated.js63
-rw-r--r--tests/unit/dialog/dialog_events.js4
-rw-r--r--tests/unit/dialog/dialog_methods.js4
-rw-r--r--tests/unit/draggable/draggable.html2
-rw-r--r--tests/unit/draggable/draggable_events.js2
-rw-r--r--tests/unit/draggable/draggable_methods.js14
-rw-r--r--tests/unit/draggable/draggable_options.js163
-rw-r--r--tests/unit/draggable/draggable_test_helpers.js4
-rw-r--r--tests/unit/droppable/droppable_methods.js29
-rw-r--r--tests/unit/progressbar/progressbar_methods.js10
-rw-r--r--tests/unit/resizable/resizable_methods.js17
-rw-r--r--tests/unit/selectable/selectable_methods.js36
-rw-r--r--tests/unit/slider/slider_methods.js3
-rw-r--r--tests/unit/slider/slider_options.js4
-rw-r--r--tests/unit/sortable/sortable_events.js27
-rw-r--r--tests/unit/sortable/sortable_methods.js35
-rw-r--r--tests/unit/sortable/sortable_options.js130
-rw-r--r--tests/unit/spinner/spinner_methods.js4
-rw-r--r--tests/unit/tabs/tabs_core.js6
-rw-r--r--tests/unit/tabs/tabs_options.js22
-rw-r--r--tests/unit/tooltip/tooltip_methods.js7
-rw-r--r--tests/unit/widget/widget_core.js53
33 files changed, 645 insertions, 313 deletions
diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js
index 79283d11c..5f6cfa8bc 100644
--- a/tests/unit/accordion/accordion_events.js
+++ b/tests/unit/accordion/accordion_events.js
@@ -6,7 +6,7 @@ var setupTeardown = TestHelpers.accordion.setupTeardown,
module( "accordion: events", setupTeardown() );
test( "create", function() {
- expect( 15 );
+ expect( 10 );
var element = $( "#list1" ),
headers = element.children( "h3" ),
@@ -18,8 +18,6 @@ test( "create", function() {
strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], contents[ 0 ], "panel" );
- equal( ui.content.length, 1, "content length" );
- strictEqual( ui.content[ 0 ], contents[ 0 ], "content" );
}
});
element.accordion( "destroy" );
@@ -31,8 +29,6 @@ test( "create", function() {
strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
equal( ui.panel.length, 1, "panel length" );
strictEqual( ui.panel[ 0 ], contents[ 2 ], "panel" );
- equal( ui.content.length, 1, "content length" );
- strictEqual( ui.content[ 0 ], contents[ 2 ], "content" );
}
});
element.accordion( "destroy" );
@@ -43,7 +39,6 @@ test( "create", function() {
create: function( event, ui ) {
equal( ui.header.length, 0, "header length" );
equal( ui.panel.length, 0, "panel length" );
- equal( ui.content.length, 0, "content length" );
}
});
element.accordion( "destroy" );
diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js
index b1123b828..7612479f7 100644
--- a/tests/unit/accordion/accordion_methods.js
+++ b/tests/unit/accordion/accordion_methods.js
@@ -14,10 +14,15 @@ test( "destroy", function() {
});
test( "enable/disable", function() {
- expect( 4 );
+ expect( 7 );
var element = $( "#list1" ).accordion();
state( element, 1, 0, 0 );
element.accordion( "disable" );
+
+ ok( element.hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" );
+ equal( element.attr( "aria-disabled" ), "true", "element gets aria-disabled" );
+ ok( element.hasClass( "ui-accordion-disabled" ), "element gets ui-accordion-disabled" );
+
// event does nothing
element.find( ".ui-accordion-header" ).eq( 1 ).trigger( "click" );
state( element, 1, 0, 0 );
diff --git a/tests/unit/all.html b/tests/unit/all.html
index ba96feef2..8dfff2a4e 100644
--- a/tests/unit/all.html
+++ b/tests/unit/all.html
@@ -20,9 +20,9 @@
"autocomplete/autocomplete.html",
"button/button.html",
"core/core.html",
+ "core/core_deprecated.html",
"datepicker/datepicker.html",
"dialog/dialog.html",
- "dialog/dialog_deprecated.html",
"draggable/draggable.html",
"droppable/droppable.html",
"effects/effects.html",
diff --git a/tests/unit/autocomplete/autocomplete_core.js b/tests/unit/autocomplete/autocomplete_core.js
index 845a3b19d..a9fc1143c 100644
--- a/tests/unit/autocomplete/autocomplete_core.js
+++ b/tests/unit/autocomplete/autocomplete_core.js
@@ -99,7 +99,7 @@ test( "allow form submit on enter when menu is not active", function() {
delay: 0,
minLength: 0
});
- element.data( "ui-autocomplete" )._move = function() {
+ element.autocomplete( "instance" )._move = function() {
didMove = true;
};
element.simulate( "keydown", { keyCode: ( isKeyUp ? $.ui.keyCode.UP : $.ui.keyCode.DOWN ) } );
@@ -114,7 +114,7 @@ test( "allow form submit on enter when menu is not active", function() {
delay: 0,
minLength: 0
});
- element.data( "ui-autocomplete" )._move = function() {
+ element.autocomplete( "instance" )._move = function() {
ok( true, "repsond to arrow" );
};
element.autocomplete( "search" );
@@ -156,7 +156,7 @@ test( "ARIA", function() {
var element = $( "#autocomplete" ).autocomplete({
source: [ "java", "javascript" ]
}),
- liveRegion = element.data( "ui-autocomplete" ).liveRegion;
+ liveRegion = element.autocomplete( "instance" ).liveRegion;
equal( liveRegion.text(), "", "Empty live region on create" );
diff --git a/tests/unit/autocomplete/autocomplete_options.js b/tests/unit/autocomplete/autocomplete_options.js
index 9f0bd2d43..c98f2c28e 100644
--- a/tests/unit/autocomplete/autocomplete_options.js
+++ b/tests/unit/autocomplete/autocomplete_options.js
@@ -88,17 +88,20 @@ asyncTest( "delay", function() {
});
asyncTest( "disabled", function() {
- expect( 2 );
+ expect( 5 );
var element = $( "#autocomplete" ).autocomplete({
source: data,
- delay: 0,
- disabled: true
+ delay: 0
}),
- menu = element.autocomplete( "widget" );
+ menu = element.autocomplete( "disable" ).autocomplete( "widget" );
element.val( "ja" ).keydown();
ok( menu.is( ":hidden" ) );
+ ok( !element.is( ".ui-state-disabled" ), "element doesn't get ui-state-disabled" );
+ ok( !element.attr( "aria-disabled" ), "element doesn't get aria-disabled" );
+ ok( menu.is( ".ui-autocomplete-disabled" ), "element gets ui-autocomplete-disabled" );
+
setTimeout(function() {
ok( menu.is( ":hidden" ) );
start();
diff --git a/tests/unit/button/button_options.js b/tests/unit/button/button_options.js
index e1931a54e..124a8699f 100644
--- a/tests/unit/button/button_options.js
+++ b/tests/unit/button/button_options.js
@@ -3,19 +3,26 @@
*/
(function($) {
-module("button: options");
+module( "button: options" );
-test("disabled, explicit value", function() {
- expect( 4 );
- $("#radio01").button({ disabled: false });
- deepEqual(false, $("#radio01").button("option", "disabled"),
- "disabled option set to false");
- deepEqual(false, $("#radio01").prop("disabled"), "element is disabled");
+test( "disabled, explicit value", function() {
+ expect( 9 );
- $("#radio02").button({ disabled: true });
- deepEqual(true, $("#radio02").button("option", "disabled"),
- "disabled option set to true");
- deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled");
+ var element = $( "#radio01" ).button({ disabled: false });
+ deepEqual( element.button( "option", "disabled" ), false, "disabled option set to false" );
+ deepEqual( element.prop( "disabled" ), false, "element is disabled" );
+
+ ok( !element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" );
+ ok( !element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" );
+
+ element = $( "#radio02" ).button({ disabled: true });
+
+ ok( element.button( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" );
+ ok( !element.button( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
+ ok( element.button( "widget" ).hasClass( "ui-button-disabled" ), "element gets ui-button-disabled" );
+
+ deepEqual( element.button( "option", "disabled" ), true, "disabled option set to true" );
+ deepEqual( element.prop( "disabled" ), true, "element is not disabled" );
});
test("disabled, null", function() {
diff --git a/tests/unit/core/core.html b/tests/unit/core/core.html
index 41c8db827..fd472d64a 100644
--- a/tests/unit/core/core.html
+++ b/tests/unit/core/core.html
@@ -117,17 +117,6 @@
<input id="dimensionlessParent-dimensionless" style="height: 0; width: 0;">
</div>
-<div id="zIndex100" style="z-index: 100; position: absolute">
- <div id="zIndexAutoWithParent">.</div>
-</div>
-<div id="zIndex100ViaCSS" class="zindex">
- <div id="zIndexAutoWithParentViaCSS">.</div>
-</div>
-<div id="zIndex100ViaCSSPositioned" class="zindex absolute">
- <div id="zIndexAutoWithParentViaCSSPositioned">.</div>
-</div>
-<div id="zIndexAutoNoParent"></div>
-
<div id="dimensions" style="float: left; height: 50px; width: 100px; margin: 1px 12px 11px 2px; border-style: solid; border-width: 3px 14px 13px 4px; padding: 5px 16px 15px 6px;"></div>
</div>
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js
index 78a225338..54d50d84e 100644
--- a/tests/unit/core/core.js
+++ b/tests/unit/core/core.js
@@ -26,25 +26,6 @@ asyncTest( "focus", function() {
});
});
-test( "zIndex", function() {
- expect( 7 );
- var el = $( "#zIndexAutoWithParent" ),
- parent = el.parent();
- equal( el.zIndex(), 100, "zIndex traverses up to find value" );
- equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" );
- equal( el.zIndex(), 200, "zIndex setter changed zIndex" );
-
- el = $( "#zIndexAutoWithParentViaCSS" );
- equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" );
-
- el = $( "#zIndexAutoWithParentViaCSSPositioned" );
- equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" );
- el.parent().zIndex( 200 );
- equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" );
-
- equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" );
-});
-
test( "innerWidth - getter", function() {
expect( 2 );
var el = $( "#dimensions" );
diff --git a/tests/unit/core/core_deprecated.html b/tests/unit/core/core_deprecated.html
new file mode 100644
index 000000000..d9c41ca39
--- /dev/null
+++ b/tests/unit/core/core_deprecated.html
@@ -0,0 +1,136 @@
+<!doctype html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title>jQuery UI Core Test Suite</title>
+
+ <script src="../../jquery.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>
+ <script src="core_deprecated.js"></script>
+
+ <script src="../swarminject.js"></script>
+ <style>
+ .zindex {
+ z-index: 100;
+ }
+ .absolute {
+ position: absolute;
+ }
+ </style>
+</head>
+<body>
+
+<h1 id="qunit-header">jQuery UI Core Test Suite</h1>
+<h2 id="qunit-banner"></h2>
+<div id="qunit-testrunner-toolbar"></div>
+<h2 id="qunit-userAgent"></h2>
+<ol id="qunit-tests"></ol>
+<div id="qunit-fixture">
+
+<img src="../images/jqueryui_32x32.png" usemap="#mymap" width="10" height="10" alt="">
+<map name="mymap">
+ <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" alt="">
+</map>
+
+<form id="formNoTabindex"></form>
+<form id="formTabindex" tabindex="1"></form>
+
+<div>
+ <input id="visibleAncestor-inputTypeNone">
+ <input type="text" id="visibleAncestor-inputTypeText">
+ <input type="checkbox" id="visibleAncestor-inputTypeCheckbox">
+ <input type="radio" id="visibleAncestor-inputTypeRadio">
+ <input type="button" id="visibleAncestor-inputTypeButton" value="visibleAncestor-inputTypeButton">
+ <input type="hidden" id="visibleAncestor-inputTypeHidden">
+ <button id="visibleAncestor-button">x</button>
+ <select id="visibleAncestor-select">
+ <option>option</option>
+ </select>
+ <textarea id="visibleAncestor-textarea">x</textarea>
+ <object id="visibleAncestor-object" codebase="about:blank">xxx</object>
+ <a href="#" id="visibleAncestor-anchorWithHref">anchor</a>
+ <a id="visibleAncestor-anchorWithoutHref">anchor</a>
+ <span id="visibleAncestor-span">x</span>
+ <div id="visibleAncestor-div">x</div>
+ <span id="visibleAncestor-spanWithTabindex" tabindex="1">x</span>
+ <div id="visibleAncestor-divWithNegativeTabindex" tabindex="-1">x</div>
+</div>
+
+<div>
+ <input id="disabledElement-inputTypeNone" disabled="disabled">
+ <input type="text" id="disabledElement-inputTypeText" disabled="disabled">
+ <input type="checkbox" id="disabledElement-inputTypeCheckbox" disabled="disabled">
+ <input type="radio" id="disabledElement-inputTypeRadio" disabled="disabled">
+ <input type="button" id="disabledElement-inputTypeButton" disabled="disabled" value="disabledElement-inputTypeButton">
+ <input type="hidden" id="disabledElement-inputTypeHidden" disabled="disabled">
+ <button id="disabledElement-button" disabled="disabled"></button>
+ <select id="disabledElement-select" disabled="disabled"></select>
+ <textarea id="disabledElement-textarea" disabled="disabled"></textarea>
+</div>
+
+<div>
+ <div id="displayNoneAncestor" style="display: none;">
+ <input id="displayNoneAncestor-input">
+ <span tabindex="1" id="displayNoneAncestor-span">.</span>
+ </div>
+
+ <div id="visibilityHiddenAncestor" style="visibility: hidden;">
+ <input id="visibilityHiddenAncestor-input">
+ <span tabindex="1" id="visibilityHiddenAncestor-span">.</span>
+ </div>
+
+ <span tabindex="1" id="displayNone-span" style="display: none;">.</span>
+ <span tabindex="1" id="visibilityHidden-span" style="visibility: hidden;">.</span>
+
+ <input id="displayNone-input" style="display: none;">
+ <input id="visibilityHidden-input" style="visibility: hidden;">
+</div>
+
+<div>
+ <input id="inputTabindex0" tabindex="0">
+ <input id="inputTabindex10" tabindex="10">
+ <input id="inputTabindex-1" tabindex="-1">
+ <input id="inputTabindex-50" tabindex="-50">
+
+ <span id="spanTabindex0" tabindex="0">.</span>
+ <span id="spanTabindex10" tabindex="10">.</span>
+ <span id="spanTabindex-1" tabindex="-1">.</span>
+ <span id="spanTabindex-50" tabindex="-50">.</span>
+</div>
+
+<div style="width: 0; height: 0;">
+ <input id="dimensionlessParent">
+ <input id="dimensionlessParent-dimensionless" style="height: 0; width: 0;">
+</div>
+
+<div id="zIndex100" style="z-index: 100; position: absolute">
+ <div id="zIndexAutoWithParent">.</div>
+</div>
+<div id="zIndex100ViaCSS" class="zindex">
+ <div id="zIndexAutoWithParentViaCSS">.</div>
+</div>
+<div id="zIndex100ViaCSSPositioned" class="zindex absolute">
+ <div id="zIndexAutoWithParentViaCSSPositioned">.</div>
+</div>
+<div id="zIndexAutoNoParent"></div>
+
+<div id="dimensions" style="float: left; height: 50px; width: 100px; margin: 1px 12px 11px 2px; border-style: solid; border-width: 3px 14px 13px 4px; padding: 5px 16px 15px 6px;"></div>
+
+</div>
+</body>
+</html>
diff --git a/tests/unit/core/core_deprecated.js b/tests/unit/core/core_deprecated.js
new file mode 100644
index 000000000..bb06f77b2
--- /dev/null
+++ b/tests/unit/core/core_deprecated.js
@@ -0,0 +1,24 @@
+(function( $ ) {
+
+module( "core - deprecated" );
+
+test( "zIndex", function() {
+ expect( 7 );
+ var el = $( "#zIndexAutoWithParent" ),
+ parent = el.parent();
+ equal( el.zIndex(), 100, "zIndex traverses up to find value" );
+ equal( parent.zIndex(200 ), parent, "zIndex setter is chainable" );
+ equal( el.zIndex(), 200, "zIndex setter changed zIndex" );
+
+ el = $( "#zIndexAutoWithParentViaCSS" );
+ equal( el.zIndex(), 0, "zIndex traverses up to find CSS value, not found because not positioned" );
+
+ el = $( "#zIndexAutoWithParentViaCSSPositioned" );
+ equal( el.zIndex(), 100, "zIndex traverses up to find CSS value" );
+ el.parent().zIndex( 200 );
+ equal( el.zIndex(), 200, "zIndex setter changed zIndex, overriding CSS" );
+
+ equal( $( "#zIndexAutoNoParent" ).zIndex(), 0, "zIndex never explicitly set in hierarchy" );
+});
+
+})( jQuery );
diff --git a/tests/unit/dialog/dialog_deprecated.html b/tests/unit/dialog/dialog_deprecated.html
deleted file mode 100644
index 1f8bac689..000000000
--- a/tests/unit/dialog/dialog_deprecated.html
+++ /dev/null
@@ -1,67 +0,0 @@
-<!doctype html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>jQuery UI Dialog Test Suite</title>
-
- <script src="../../jquery.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({
- css: [ "ui.core", "ui.dialog" ],
- js: [
- "ui/jquery.ui.core.js",
- "ui/jquery.ui.widget.js",
- "ui/jquery.ui.position.js",
- "ui/jquery.ui.mouse.js",
- "ui/jquery.ui.draggable.js",
- "ui/jquery.ui.resizable.js",
- "ui/jquery.ui.button.js",
- "ui/jquery.ui.effect.js",
- "ui/jquery.ui.effect-blind.js",
- "ui/jquery.ui.effect-clip.js",
- "ui/jquery.ui.effect-explode.js",
- "ui/jquery.ui.dialog.js"
- ]
- });
- </script>
-
- <script src="dialog_common.js"></script>
- <script src="dialog_core.js"></script>
- <script src="dialog_events.js"></script>
- <script src="dialog_methods.js"></script>
- <script src="dialog_options.js"></script>
- <script src="dialog_test_helpers.js"></script>
- <script src="dialog_deprecated.js"></script>
-
- <script src="../swarminject.js"></script>
-</head>
-<body>
-
-<h1 id="qunit-header">jQuery UI Dialog Test Suite</h1>
-<h2 id="qunit-banner"></h2>
-<div id="qunit-testrunner-toolbar"></div>
-<h2 id="qunit-userAgent"></h2>
-<ol id="qunit-tests"></ol>
-<div id="qunit-fixture">
- <div id="dialog1"></div>
- <div id="dialog2"></div>
- <div id="form-dialog" title="Profile Information">
- <fieldset>
- <legend>Please share some personal information</legend>
- <label for="favorite-animal">Your favorite animal</label><input id="favorite-animal">
- <label for="favorite-color">Your favorite color</label><input id="favorite-color">
- </fieldset>
- <div role="group" aria-describedby="section2">
- <p id="section2">Some more (optional) information</p>
- <label for="favorite-food">Favorite food</label><input id="favorite-food">
- </div>
- </div>
- <div class="wrap" id="wrap1"></div>
- <div class="wrap" id="wrap2"></div>
-</div>
-</body>
-</html>
diff --git a/tests/unit/dialog/dialog_deprecated.js b/tests/unit/dialog/dialog_deprecated.js
deleted file mode 100644
index ff6284ea5..000000000
--- a/tests/unit/dialog/dialog_deprecated.js
+++ /dev/null
@@ -1,63 +0,0 @@
-module("dialog (deprecated): position option with string and array");
-
-test( "position, right bottom on window w/array", function() {
- expect( 2 );
-
- // dialogs alter the window width and height in FF and IE7
- // so we collect that information before creating the dialog
- // Support: FF, IE7
- var winWidth = $( window ).width(),
- winHeight = $( window ).height(),
- element = $("<div></div>").dialog({ position: [ "right", "bottom" ] }),
- dialog = element.dialog("widget"),
- offset = dialog.offset();
- closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window w/array" );
- closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window w/array" );
- element.remove();
-});
-
-test( "position, right bottom on window", function() {
- expect( 2 );
-
- // dialogs alter the window width and height in FF and IE7
- // so we collect that information before creating the dialog
- // Support: FF, IE7
- var winWidth = $( window ).width(),
- winHeight = $( window ).height(),
- element = $("<div></div>").dialog({ position: "right bottom" }),
- dialog = element.dialog("widget"),
- offset = dialog.offset();
- closeEnough( offset.left, winWidth - dialog.outerWidth() + $( window ).scrollLeft(), 1, "offset left of right bottom on window" );
- closeEnough( offset.top, winHeight - dialog.outerHeight() + $( window ).scrollTop(), 1, "offset top of right bottom on window" );
- element.remove();
-});
-
-test("position, offset from top left w/array", function() {
- expect( 2 );
- var element = $("<div></div>").dialog({ position: [10, 10] }),
- dialog = element.dialog("widget"),
- offset = dialog.offset();
- closeEnough(offset.left, 10 + $(window).scrollLeft(), 1);
- closeEnough(offset.top, 10 + $(window).scrollTop(), 1);
- element.remove();
-});
-
-test("position, top on window", function() {
- expect( 2 );
- var element = $("<div></div>").dialog({ position: "top" }),
- dialog = element.dialog("widget"),
- offset = dialog.offset();
- closeEnough(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft(), 1);
- closeEnough(offset.top, $(window).scrollTop(), 1);
- element.remove();
-});
-
-test("position, left on window", function() {
- expect( 2 );
- var element = $("<div></div>").dialog({ position: "left" }),
- dialog = element.dialog("widget"),
- offset = dialog.offset();
- closeEnough(offset.left, 0, 1);
- closeEnough(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop(), 1);
- element.remove();
-});
diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js
index 7bcd5673e..1384500f6 100644
--- a/tests/unit/dialog/dialog_events.js
+++ b/tests/unit/dialog/dialog_events.js
@@ -11,7 +11,7 @@ test("open", function() {
var element = $("<div></div>");
element.dialog({
open: function(ev, ui) {
- ok(element.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
+ ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set");
ok(true, "autoOpen: true fires open callback");
equal(this, element[0], "context of callback");
equal(ev.type, "dialogopen", "event type in callback");
@@ -30,7 +30,7 @@ test("open", function() {
deepEqual(ui, {}, "ui hash in callback");
}
}).bind("dialogopen", function(ev, ui) {
- ok(element.data("ui-dialog")._isOpen, "interal _isOpen flag is set");
+ ok(element.dialog( "instance" )._isOpen, "interal _isOpen flag is set");
ok(true, "dialog('open') fires open event");
equal(this, element[0], "context of event");
deepEqual(ui, {}, "ui hash in event");
diff --git a/tests/unit/dialog/dialog_methods.js b/tests/unit/dialog/dialog_methods.js
index 6de185513..2bb06ab46 100644
--- a/tests/unit/dialog/dialog_methods.js
+++ b/tests/unit/dialog/dialog_methods.js
@@ -101,11 +101,13 @@ test("#4980: Destroy should place element back in original DOM position", functi
});
test( "enable/disable disabled", function() {
- expect( 2 );
+ expect( 4 );
var element = $( "<div></div>" ).dialog();
element.dialog( "disable" );
equal(element.dialog( "option", "disabled" ), false, "disable method doesn't do anything" );
ok( !element.dialog( "widget" ).hasClass( "ui-dialog-disabled" ), "disable method doesn't add ui-dialog-disabled class" );
+ ok( !element.dialog( "widget" ).hasClass( "ui-state-disabled" ), "disable method doesn't add ui-state-disabled class" );
+ ok( !element.dialog( "widget" ).attr( "aria-disabled" ), "disable method doesn't add aria-disabled" );
});
test("close", function() {
diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html
index 6380f3e85..3d1d3326e 100644
--- a/tests/unit/draggable/draggable.html
+++ b/tests/unit/draggable/draggable.html
@@ -48,7 +48,7 @@
<div id="qunit-fixture">
<div id="main"></div>
<div id="draggable1" style="background: green; width: 200px; height: 100px;">Relative</div>
- <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span>Absolute</span></div>
+ <div id="draggable2" style="background: green; width: 200px; height: 100px; position: absolute; top: 10px; left: 10px;"><span><em>Absolute</em></span></div>
<div id="droppable" style="background: green; width: 200px; height: 100px; position: absolute; top: 110px; left: 110px;"><span>Absolute</span></div>
<div style="width: 1px; height: 1000px;"></div>
<div style="position: absolute; width: 1px; height: 2000px;"></div>
diff --git a/tests/unit/draggable/draggable_events.js b/tests/unit/draggable/draggable_events.js
index 199561be3..bbaaaeb15 100644
--- a/tests/unit/draggable/draggable_events.js
+++ b/tests/unit/draggable/draggable_events.js
@@ -117,7 +117,7 @@ test( "stopping the stop callback", function() {
dy: 10
});
- ok( element.data("ui-draggable").helper, "the clone should not be deleted if the stop callback is stopped" );
+ ok( element.draggable( "instance" ).helper, "the clone should not be deleted if the stop callback is stopped" );
});
diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js
index 901c261d6..63a19e26d 100644
--- a/tests/unit/draggable/draggable_methods.js
+++ b/tests/unit/draggable/draggable_methods.js
@@ -74,16 +74,16 @@ test( "enable", function() {
});
test( "disable", function() {
- expect( 7 );
+ expect( 10 );
- element = $("#draggable2").draggable({ disabled: false });
+ element = $( "#draggable2" ).draggable({ disabled: false });
TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" );
- element.draggable("disable");
+ element.draggable( "disable" );
TestHelpers.draggable.shouldNotMove( element, ".draggable('disable')" );
equal( element.draggable( "option", "disabled" ), true, "disabled option getter" );
- element.draggable("destroy");
+ element.draggable( "destroy" );
element.draggable({ disabled: false });
TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" );
@@ -91,8 +91,12 @@ test( "disable", function() {
equal( element.draggable( "option", "disabled" ), true, "disabled option setter" );
TestHelpers.draggable.shouldNotMove( element, ".draggable('option', 'disabled', true)" );
+ ok( !element.draggable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
+ ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
+ ok( element.draggable( "widget" ).hasClass( "ui-draggable-disabled" ), "element gets ui-draggable-disabled" );
+
var expected = element.draggable(),
- actual = expected.draggable("disable");
+ actual = expected.draggable( "disable" );
equal( actual, expected, "disable is chainable" );
});
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index ccbe7224a..f4fca0b2e 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -346,6 +346,37 @@ test( "{ containment: 'parent' }, absolute", function() {
deepEqual( offsetAfter, expected, "compare offset to parent" );
});
+test( "containment, account for border", function() {
+ expect( 2 );
+
+ var el = $("#draggable1").appendTo("#main"),
+ parent = el.parent().css({
+ height: "100px",
+ width: "100px",
+ borderStyle: "solid",
+ borderWidth: "5px 10px 15px 20px"
+ }),
+ parentBottom = parent.offset().top + parent.outerHeight(),
+ parentRight = parent.offset().left + parent.outerWidth(),
+ parentBorderBottom = TestHelpers.draggable.border( parent, "bottom" ),
+ parentBorderRight = TestHelpers.draggable.border( parent, "right" );
+
+ el.css({
+ height: "5px",
+ width: "5px"
+ }).draggable({ containment: "parent" });
+
+ el.simulate( "drag", {
+ dx: 100,
+ dy: 100
+ });
+
+ equal( el.offset().top, parentBottom - parentBorderBottom - el.height(),
+ "The draggable should be on top of its parent's bottom border" );
+ equal( el.offset().left, parentRight - parentBorderRight - el.width(),
+ "The draggable should be to the right of its parent's right border" );
+});
+
test( "containment, default, switching after initialization", function() {
expect( 2 );
@@ -572,39 +603,15 @@ test( "grid, switching after initialization", function() {
});
test( "{ handle: 'span' }", function() {
- expect( 2 );
+ expect( 3 );
var element = $( "#draggable2" ).draggable({ handle: "span" });
TestHelpers.draggable.testDrag( element, "#draggable2 span", 50, 50, 50, 50, "drag span" );
+ TestHelpers.draggable.testDrag( element, "#draggable2 span em", 50, 50, 50, 50, "drag span child" );
TestHelpers.draggable.shouldNotMove( element, "drag element" );
});
-/*
-test( "{ handle: Selectors }, matching parent selector", function() {
-
- expect( 4 );
-
- var element = $( "#draggable2" ).draggable({ handle: "span a" });
-
- $( "#qunit-fixture" ).append( "<span id='wrapping'><a></a></span>" );
-
- element.find( "span" ).append( "<a>" );
-
- $( "#wrapping a" ).append( element );
-
- TestHelpers.draggable.testDrag( element, "#draggable2 span a", 50, 50, 50, 50, "drag span child" );
- TestHelpers.draggable.shouldNotMove( $( "#wrapping a" ) );
-
- $( "#draggable2" ).draggable( "option", "handle", "span > a" );
- $( "#draggable2" ).find( "a" ).append( "<a>" );
-
- TestHelpers.draggable.testDrag( element, $( "#draggable2 span a" ).first(), 50, 50, 50, 50, "drag span child" );
- TestHelpers.draggable.shouldNotMove( $( "#draggable2 span a" ).last() );
-
-});
-*/
-
test( "handle, default, switching after initialization", function() {
expect( 6 );
@@ -1096,6 +1103,40 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() {
TestHelpers.draggable.restoreScroll( document );
});
+test( "#6817: auto scroll goes double distance when dragging", function() {
+ expect( 2 );
+
+ var offsetBefore,
+ distance = 10,
+ viewportHeight = $( window ).height(),
+ element = $( "#draggable1" ).draggable({
+ scroll: true,
+ stop: function( e, ui ) {
+ equal( ui.offset.top, newY, "offset of item matches pointer position after scroll" );
+ equal( ui.offset.top - offsetBefore.top, distance, "offset of item only moves expected distance after scroll" );
+ }
+ }),
+ scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
+ oldY = viewportHeight - scrollSensitivity,
+ newY = oldY + distance;
+
+ element.offset({
+ top: oldY,
+ left: 1
+ });
+
+ offsetBefore = element.offset();
+
+ element.simulate( "drag", {
+ handle: "corner",
+ dx: 1,
+ y: newY,
+ moves: 1
+ });
+
+ TestHelpers.draggable.restoreScroll( document );
+});
+
test( "snap, snapMode, and snapTolerance", function() {
expect( 9 );
@@ -1216,6 +1257,76 @@ test( "snap, snapMode, and snapTolerance", function() {
deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap on the inner snapTolerance area when snapMode is outer" );
});
+test( "#8459: element can snap to an element that was removed during drag", function() {
+ expect( 1 );
+
+ var newX, newY,
+ snapTolerance = 15,
+ element = $( "#draggable1" ).draggable({
+ snap: true,
+ snapMode: "both",
+ snapTolerance: snapTolerance,
+ start: function() {
+ element2.remove();
+ }
+ }),
+ element2 = $( "#draggable2" ).draggable();
+
+ element.offset({
+ top: 1,
+ left: 1
+ });
+
+ newX = element2.offset().left - element.outerWidth() - snapTolerance + 1;
+ newY = element2.offset().top;
+
+ element.simulate( "drag", {
+ handle: "corner",
+ x: newX,
+ y: newY,
+ moves: 1
+ });
+
+ deepEqual( element.offset(), { top: newY, left: newX }, "doesn't snap to a removed element" );
+});
+
+test( "#8165: Snapping large rectangles to small rectangles doesn't snap properly", function() {
+ expect( 1 );
+
+ var snapTolerance = 20,
+ y = 1,
+ element = $( "#draggable1" )
+ .css({
+ width: "50px",
+ height: "200px"
+ }).offset({
+ top: y,
+ left: 1
+ }),
+ element2 = $( "#draggable2" )
+ .css({
+ width: "50px",
+ height: "50px"
+ }).offset({
+ top: y + snapTolerance + 1,
+ left: 200
+ }),
+ newX = element2.offset().left - element.outerWidth() - snapTolerance + 1;
+
+ $( "#draggable1, #draggable2" ).draggable({
+ snap: true,
+ snapTolerance: snapTolerance
+ });
+
+ element.simulate( "drag", {
+ handle: "corner",
+ x: newX,
+ moves: 1
+ });
+
+ notDeepEqual( element.offset(), { top: y, left: newX }, "snaps even if only a side (not a corner) is inside the snapTolerance" );
+});
+
test( "stack", function() {
expect( 2 );
diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js
index e1c79c6cc..44e37c559 100644
--- a/tests/unit/draggable/draggable_test_helpers.js
+++ b/tests/unit/draggable/draggable_test_helpers.js
@@ -60,7 +60,7 @@ TestHelpers.draggable = {
},
trackMouseCss : function( el ) {
- el.on( "drag", function() {
+ el.bind( "drag", function() {
el.data( "last_dragged_cursor", $("body").css("cursor") );
});
},
@@ -69,7 +69,7 @@ TestHelpers.draggable = {
// appendTo ignored without being clone
el.draggable( "option", "helper", "clone" );
- el.on( "drag", function(e,ui) {
+ el.bind( "drag", function(e,ui) {
// Get what parent is at time of drag
el.data( "last_dragged_parent", ui.helper.parent()[0] );
});
diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js
index 2b452a63d..f7682d262 100644
--- a/tests/unit/droppable/droppable_methods.js
+++ b/tests/unit/droppable/droppable_methods.js
@@ -63,26 +63,29 @@ test("enable", function() {
equal(actual, expected, "enable is chainable");
});
-test("disable", function() {
- expect(7);
+test( "disable", function() {
+ expect( 10 );
- var el, actual, expected;
+ var actual, expected,
+ element = $( "#droppable1" ).droppable({ disabled: false });
- el = $("#droppable1").droppable({ disabled: false });
TestHelpers.droppable.shouldDrop();
- el.droppable("disable");
+ element.droppable( "disable" );
TestHelpers.droppable.shouldNotDrop();
- equal(el.droppable("option", "disabled"), true, "disabled option getter");
- el.droppable("destroy");
- el.droppable({ disabled: false });
+ equal( element.droppable( "option", "disabled" ), true, "disabled option getter" );
+ element.droppable( "destroy" );
+ element.droppable({ disabled: false });
TestHelpers.droppable.shouldDrop();
- el.droppable("option", "disabled", true);
- equal(el.droppable("option", "disabled"), true, "disabled option setter");
+ element.droppable( "option", "disabled", true );
+ ok( !element.droppable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
+ ok( !element.droppable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
+ ok( element.droppable( "widget" ).hasClass( "ui-droppable-disabled" ), "element gets ui-droppable-disabled" );
+ equal( element.droppable( "option", "disabled" ), true, "disabled option setter" );
TestHelpers.droppable.shouldNotDrop();
- expected = $("<div></div>").droppable(),
- actual = expected.droppable("disable");
- equal(actual, expected, "disable is chainable");
+ expected = $( "<div></div>" ).droppable();
+ actual = expected.droppable( "disable" );
+ equal( actual, expected, "disable is chainable" );
});
})(jQuery);
diff --git a/tests/unit/progressbar/progressbar_methods.js b/tests/unit/progressbar/progressbar_methods.js
index cf7faf6af..004eacf90 100644
--- a/tests/unit/progressbar/progressbar_methods.js
+++ b/tests/unit/progressbar/progressbar_methods.js
@@ -7,6 +7,16 @@ test( "destroy", function() {
});
});
+test( "disable", function() {
+ expect( 3 );
+
+ var element = $( "#progressbar" ).progressbar().progressbar( "disable" );
+
+ ok( element.progressbar( "widget" ).hasClass( "ui-state-disabled" ), "element gets ui-state-disabled" );
+ ok( element.progressbar( "widget" ).attr( "aria-disabled" ), "element gets aria-disabled" );
+ ok( element.progressbar( "widget" ).hasClass( "ui-progressbar-disabled" ), "element gets ui-progressbar-disabled" );
+});
+
test( "value", function() {
expect( 3 );
diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js
index b12f3035a..abb8951f9 100644
--- a/tests/unit/resizable/resizable_methods.js
+++ b/tests/unit/resizable/resizable_methods.js
@@ -3,10 +3,19 @@
*/
(function($) {
-module("resizable: methods");
+module( "resizable: methods" );
-// this is here to make JSHint pass "unused", and we don't want to
-// remove the parameter for when we finally implement
-$.noop();
+test( "disable", function() {
+ expect( 5 );
+
+ var element = $( "#resizable1" ).resizable({ disabled: false }),
+ chainable = element.resizable( "disable" );
+
+ ok( !element.resizable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
+ ok( !element.resizable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
+ ok( element.resizable( "widget" ).hasClass( "ui-resizable-disabled" ), "element gets ui-resizable-disabled" );
+ equal( element.resizable( "option", "disabled" ), true, "disabled option setter" );
+ equal( chainable, element, "disable is chainable" );
+});
})(jQuery);
diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js
index 72f9bb28d..179d4ecd6 100644
--- a/tests/unit/selectable/selectable_methods.js
+++ b/tests/unit/selectable/selectable_methods.js
@@ -71,34 +71,40 @@ test("enable", function() {
equal(actual, expected, "enable is chainable");
});
-test("disable", function() {
- expect(3);
- var expected, actual,
+test( "disable", function() {
+ expect( 6 );
+ var chainable,
fired = false,
- el = $("#selectable1");
+ element = $( "#selectable1" );
- el.selectable({
+ element.selectable({
disabled: false,
- start: function() { fired = true; }
+ start: function() {
+ fired = true;
+ }
});
- el.simulate( "drag", {
+ element.simulate( "drag", {
dx: 20,
dy: 20
});
- equal(fired, true, "start fired");
- el.selectable("disable");
+ equal( fired, true, "start fired" );
+
+ chainable = element.selectable( "disable" );
fired = false;
- el.simulate( "drag", {
+ element.simulate( "drag", {
dx: 20,
dy: 20
});
- equal(fired, false, "start fired");
- el.selectable("destroy");
+ equal( fired, false, "start fired" );
- expected = $("<div></div>").selectable();
- actual = expected.selectable("disable");
- equal(actual, expected, "disable is chainable");
+ ok( !element.selectable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
+ ok( !element.selectable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
+ ok( element.selectable( "widget" ).hasClass( "ui-selectable-disabled" ), "element gets ui-selectable-disabled" );
+
+ element.selectable( "destroy" );
+
+ equal( chainable, element, "disable is chainable" );
});
})(jQuery);
diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js
index 75df230a6..bd9023133 100644
--- a/tests/unit/slider/slider_methods.js
+++ b/tests/unit/slider/slider_methods.js
@@ -49,7 +49,7 @@ test( "enable", function() {
});
test( "disable", function() {
- expect( 5 );
+ expect( 6 );
var element,
expected = $( "<div></div>" ).slider(),
actual = expected.slider( "disable" );
@@ -61,6 +61,7 @@ test( "disable", function() {
element.slider( "disable" );
ok( element.hasClass( "ui-state-disabled" ), "slider has ui-state-disabled class after disable method call" );
ok( element.hasClass( "ui-slider-disabled" ), "slider has ui-slider-disabled class after disable method call" );
+ ok( !element.attr( "aria-disabled" ), "slider does not have aria-disabled attr after disable method call" );
});
test( "value", function() {
diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js
index f46dbde99..3a6f55390 100644
--- a/tests/unit/slider/slider_options.js
+++ b/tests/unit/slider/slider_options.js
@@ -185,8 +185,8 @@ test( "values", function() {
});
notStrictEqual(
- ranges.eq( 0 ).data( "ui-slider" ).options.values,
- ranges.eq( 1 ).data( "ui-slider" ).options.values,
+ ranges.eq( 0 ).slider( "instance" ).options.values,
+ ranges.eq( 1 ).slider( "instance" ).options.values,
"multiple range sliders should not have a reference to the same options.values array"
);
diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js
index 1b8165acb..46a493b3e 100644
--- a/tests/unit/sortable/sortable_events.js
+++ b/tests/unit/sortable/sortable_events.js
@@ -231,11 +231,34 @@ test("receive", function() {
test("remove", function() {
ok(false, "missing test - untested code is broken code.");
});
+*/
-test("over", function() {
- ok(false, "missing test - untested code is broken code.");
+test( "over", function() {
+ expect( 8 );
+
+ var hash,
+ overCount = 0;
+
+ $( "#sortable" ).sortable({
+ over: function( e, ui ) {
+ hash = ui;
+ overCount++;
+ }
+ }).find( "li:eq(0)" ).simulate( "drag", {
+ dy: 20
+ });
+
+ ok( hash, "stop event triggered" );
+ ok( hash.helper, "UI should not include: helper" );
+ ok( hash.placeholder, "UI hash includes: placeholder" );
+ ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
+ ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
+ ok( hash.item, "UI hash includes: item" );
+ ok( hash.sender, "UI hash does not include: sender" );
+ equal( overCount, 1, "over fires only once" );
});
+/*
test("out", function() {
ok(false, "missing test - untested code is broken code.");
});
diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js
index 07a7bc77d..f3fe240e7 100644
--- a/tests/unit/sortable/sortable_methods.js
+++ b/tests/unit/sortable/sortable_methods.js
@@ -64,29 +64,30 @@ test("enable", function() {
equal(actual, expected, "enable is chainable");
});
-test("disable", function() {
- expect(7);
+test( "disable", function() {
+ expect( 9 );
- var el, actual, expected;
+ var chainable,
+ element = $( "#sortable" ).sortable({ disabled: false });
- el = $("#sortable").sortable({ disabled: false });
- TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })");
+ TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
- el.sortable("disable");
- TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, "disabled.sortable getter");
+ chainable = element.sortable( "disable" );
+ TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" );
- el.sortable("destroy");
+ element.sortable( "destroy" );
- el.sortable({ disabled: false });
- TestHelpers.sortable.sort($("li", el)[0], 0, 44, 2, ".sortable({ disabled: false })");
- el.sortable("option", "disabled", true);
- equal(el.sortable("option", "disabled"), true, "disabled option setter");
- ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction");
- TestHelpers.sortable.sort($("li", el)[0], 0, 44, 0, ".sortable('option', 'disabled', true)");
+ element.sortable({ disabled: false });
+ TestHelpers.sortable.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" );
+ element.sortable( "option", "disabled", true);
+ equal( element.sortable( "option", "disabled" ), true, "disabled option setter" );
- expected = $("<div></div>").sortable(),
- actual = expected.sortable("disable");
- equal(actual, expected, "disable is chainable");
+ ok( !element.sortable( "widget" ).hasClass( "ui-state-disabled" ), "element does not get ui-state-disabled" );
+ ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
+ ok( element.sortable( "widget" ).hasClass( "ui-sortable-disabled" ), "element gets ui-sortable-disabled" );
+
+ TestHelpers.sortable.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" );
+ equal( chainable, element, "disable is chainable" );
});
})(jQuery);
diff --git a/tests/unit/sortable/sortable_options.js b/tests/unit/sortable/sortable_options.js
index caba0a777..8dcf0e82f 100644
--- a/tests/unit/sortable/sortable_options.js
+++ b/tests/unit/sortable/sortable_options.js
@@ -13,23 +13,100 @@ test("{ appendTo: 'parent' }, default", function() {
test("{ appendTo: Selector }", function() {
ok(false, "missing test - untested code is broken code.");
});
+*/
-test("{ axis: false }, default", function() {
- ok(false, "missing test - untested code is broken code.");
+test( "{ axis: false }, default", function() {
+ expect( 2 );
+
+ var offsetAfter,
+ element = $( "#sortable" ).sortable({
+ axis: false,
+ change: function() {
+ offsetAfter = item.offset();
+ notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: false" );
+ notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: false" );
+ }
+ }),
+ item = element.find( "li" ).eq( 0 ),
+ offsetBefore = item.offset();
+
+ item.simulate( "drag", {
+ dx: 50,
+ dy: 25,
+ moves: 1
+ });
});
-test("{ axis: 'x' }", function() {
- ok(false, "missing test - untested code is broken code.");
+test( "{ axis: 'x' }", function() {
+ expect( 2 );
+
+ var offsetAfter,
+ element = $( "#sortable" ).sortable({
+ axis: "x",
+ change: function() {
+ offsetAfter = item.offset();
+ notEqual( offsetAfter.left, offsetBefore.left, "x axis not constrained when axis: x" );
+ equal( offsetAfter.top, offsetBefore.top, "y axis constrained when axis: x" );
+ }
+ }),
+ item = element.find( "li" ).eq( 0 ),
+ offsetBefore = item.offset();
+
+ item.simulate( "drag", {
+ dx: 50,
+ dy: 25,
+ moves: 1
+ });
});
-test("{ axis: 'y' }", function() {
- ok(false, "missing test - untested code is broken code.");
+test( "{ axis: 'y' }", function() {
+ expect( 2 );
+
+ var offsetAfter,
+ element = $( "#sortable" ).sortable({
+ axis: "y",
+ change: function() {
+ offsetAfter = item.offset();
+ equal( offsetAfter.left, offsetBefore.left, "x axis constrained when axis: y" );
+ notEqual( offsetAfter.top, offsetBefore.top, "y axis not constrained when axis: y" );
+ }
+ }),
+ item = element.find( "li" ).eq( 0 ),
+ offsetBefore = item.offset();
+
+ item.simulate( "drag", {
+ dx: 50,
+ dy: 25,
+ moves: 1
+ });
});
-test("{ axis: ? }, unexpected", function() {
- ok(false, "missing test - untested code is broken code.");
+asyncTest( "#7415: Incorrect revert animation with axis: 'y'", function() {
+ expect( 2 );
+ var expectedLeft,
+ element = $( "#sortable" ).sortable({
+ axis: "y",
+ revert: true,
+ stop: start,
+ sort: function() {
+ expectedLeft = item.css( "left" );
+ }
+ }),
+ item = element.find( "li" ).eq( 0 );
+
+ item.simulate( "drag", {
+ dy: 300,
+ dx: 50
+ });
+
+ setTimeout(function() {
+ var top = parseFloat( item.css( "top" ) );
+ equal( item.css( "left" ), expectedLeft, "left not animated" );
+ ok( top > 0 && top < 300, "top is animated" );
+ }, 100 );
});
+/*
test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
ok(false, "missing test - untested code is broken code.");
});
@@ -37,7 +114,44 @@ test("{ cancel: 'input,textarea,button,select,option' }, default", function() {
test("{ cancel: Selector }", function() {
ok(false, "missing test - untested code is broken code.");
});
+*/
+
+test( "#8792: issues with floated items in connected lists", function() {
+ expect( 2 );
+
+ var element,
+ changeCount = 0;
+ $( "#qunit-fixture" )
+ .html( "<ul class='c'><li>a</li><li>a</li></ul><ul class='c'><li>a</li><li>a</li></ul>" )
+ .find( "ul" ).css({ "float": "left", width: "100px" }).end()
+ .find( "li" ).css({ "float": "left", width: "50px", height: "50px" });
+
+ $( "#qunit-fixture .c" ).sortable({
+ connectWith: "#qunit-fixture .c",
+ change: function() {
+ changeCount++;
+ }
+ });
+
+ element = $( "#qunit-fixture li:eq(0)" );
+
+ element.simulate( "drag", {
+ dx: 51,
+ moves: 15
+ });
+
+ equal( changeCount, 1, "change fired only once (no jitters) when dragging a floated sortable in it's own container" );
+
+ element.simulate( "drag", {
+ dx: 50,
+ moves: 15
+ });
+
+ equal( changeCount, 3, "change fired once for each expected change when dragging a floated sortable to a connected container" );
+});
+
+/*
test("{ connectWith: false }, default", function() {
ok(false, "missing test - untested code is broken code.");
});
diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js
index af872f257..4f44a73ae 100644
--- a/tests/unit/spinner/spinner_methods.js
+++ b/tests/unit/spinner/spinner_methods.js
@@ -12,7 +12,7 @@ test( "destroy", function() {
});
test( "disable", function() {
- expect( 14 );
+ expect( 16 );
var element = $( "#spin" ).val( 2 ).spinner(),
wrapper = $( "#spin" ).spinner( "widget" );
@@ -21,6 +21,8 @@ test( "disable", function() {
element.spinner( "disable" );
ok( wrapper.hasClass( "ui-spinner-disabled" ), "after: wrapper has ui-spinner-disabled class" );
+ ok( wrapper.hasClass( "ui-state-disabled" ), "after: wrapper has ui-state-disabled class" );
+ ok( !wrapper.attr( "aria-disabled" ), "after: wrapper does not have aria-disabled attr" );
ok( element.is( ":disabled"), "after: input has disabled attribute" );
simulateKeyDownUp( element, $.ui.keyCode.UP );
diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js
index 5f70206dc..cc4f0460c 100644
--- a/tests/unit/tabs/tabs_core.js
+++ b/tests/unit/tabs/tabs_core.js
@@ -33,7 +33,7 @@ test( "nested list", function() {
expect( 1 );
var element = $( "#tabs6" ).tabs();
- equal( element.data( "ui-tabs" ).anchors.length, 2, "should contain 2 tab" );
+ equal( element.tabs( "instance" ).anchors.length, 2, "should contain 2 tab" );
});
test( "disconnected from DOM", function() {
@@ -155,7 +155,7 @@ asyncTest( "keyboard support - LEFT, RIGHT, UP, DOWN, HOME, END, SPACE, ENTER",
panels = element.find( ".ui-tabs-panel" ),
keyCode = $.ui.keyCode;
- element.data( "ui-tabs" ).delay = 50;
+ element.tabs( "instance" ).delay = 50;
equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
tabs.eq( 0 ).simulate( "focus" );
@@ -306,7 +306,7 @@ asyncTest( "keyboard support - CTRL navigation", function() {
panels = element.find( ".ui-tabs-panel" ),
keyCode = $.ui.keyCode;
- element.data( "ui-tabs" ).delay = 50;
+ element.tabs( "instance" ).delay = 50;
equal( tabs.filter( ".ui-state-focus" ).length, 0, "no tabs focused on init" );
tabs.eq( 0 ).simulate( "focus" );
diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js
index c78c42b58..51212b8f0 100644
--- a/tests/unit/tabs/tabs_options.js
+++ b/tests/unit/tabs/tabs_options.js
@@ -144,24 +144,40 @@ test( "{ collapsible: true }", function() {
});
test( "disabled", function() {
- expect( 10 );
+ expect( 22 );
// fully enabled by default
var element = $( "#tabs1" ).tabs();
disabled( element, false );
+ ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" );
+ ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" );
+ ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
+
// disable single tab
element.tabs( "option", "disabled", [ 1 ] );
disabled( element, [ 1 ] );
+ ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" );
+ ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" );
+ ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
+
// disabled active tab
element.tabs( "option", "disabled", [ 0, 1 ] );
disabled( element, [ 0, 1 ] );
+ ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" );
+ ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" );
+ ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
+
// disable all tabs
element.tabs( "option", "disabled", [ 0, 1, 2 ] );
disabled( element, true );
+ ok( !element.tabs( "widget" ).hasClass( "ui-state-disabled" ), "after: wrapper doesn't have ui-state-disabled class" );
+ ok( !element.tabs( "widget" ).hasClass( "ui-tabs-disabled" ), "after: wrapper doesn't have ui-tabs-disabled class" );
+ ok( !element.tabs( "widget" ).attr( "aria-disabled" ), "after: wrapper doesn't have aria-disabled attr" );
+
// enable all tabs
element.tabs( "option", "disabled", [] );
disabled( element, false );
@@ -298,7 +314,7 @@ test( "hide and show: false", function() {
show: false,
hide: false
}),
- widget = element.data( "ui-tabs" ),
+ widget = element.tabs( "instance" ),
panels = element.find( ".ui-tabs-panel" );
widget._show = function() {
ok( false, "_show() called" );
@@ -319,7 +335,7 @@ asyncTest( "hide and show - animation", function() {
show: "drop",
hide: 2000
}),
- widget = element.data( "ui-tabs" ),
+ widget = element.tabs( "instance" ),
panels = element.find( ".ui-tabs-panel" );
widget._show = function( element, options, callback ) {
strictEqual( element[ 0 ], panels[ 1 ], "correct element in _show()" );
diff --git a/tests/unit/tooltip/tooltip_methods.js b/tests/unit/tooltip/tooltip_methods.js
index c846d216c..a557ff943 100644
--- a/tests/unit/tooltip/tooltip_methods.js
+++ b/tests/unit/tooltip/tooltip_methods.js
@@ -54,7 +54,7 @@ test( "open/close with tracking", function() {
});
test( "enable/disable", function() {
- expect( 7 );
+ expect( 10 );
$.fx.off = true;
var tooltip,
element = $( "#tooltipped1" ).tooltip();
@@ -66,6 +66,11 @@ test( "enable/disable", function() {
element.tooltip( "disable" );
equal( $( ".ui-tooltip" ).length, 0, "no tooltip when disabled" );
+
+ ok( !element.tooltip( "widget" ).hasClass( "ui-state-disabled" ), "element doesn't get ui-state-disabled" );
+ ok( !element.tooltip( "widget" ).attr( "aria-disabled" ), "element doesn't get aria-disabled" );
+ ok( !element.tooltip( "widget" ).hasClass( "ui-tooltip-disabled" ), "element doesn't get ui-tooltip-disabled" );
+
// support: jQuery <1.6.2
// support: IE <8
// We should use strictEqual( ..., undefined ) when dropping jQuery 1.6.1 support (or IE6/7)
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js
index 8102b1f4f..0d97742ff 100644
--- a/tests/unit/widget/widget_core.js
+++ b/tests/unit/widget/widget_core.js
@@ -43,28 +43,28 @@ test( "element normalization", function() {
// workaround for core ticket #8381
this.element.appendTo( "#qunit-fixture" );
ok( this.element.is( "div" ), "generated div" );
- deepEqual( this.element.data( "ui-testWidget" ), this, "instance stored in .data()" );
+ deepEqual( this.element.testWidget( "instance" ), this, "instance stored in .data()" );
};
$.ui.testWidget();
$.ui.testWidget.prototype.defaultElement = "<span data-test='pass'></span>";
$.ui.testWidget.prototype._create = function() {
ok( this.element.is( "span[data-test=pass]" ), "generated span with properties" );
- deepEqual( this.element.data( "ui-testWidget" ), this, "instace stored in .data()" );
+ deepEqual( this.element.testWidget( "instance" ), this, "instace stored in .data()" );
};
$.ui.testWidget();
elem = $( "<input>" );
$.ui.testWidget.prototype._create = function() {
deepEqual( this.element[ 0 ], elem[ 0 ], "from element" );
- deepEqual( elem.data( "ui-testWidget" ), this, "instace stored in .data()" );
+ deepEqual( elem.testWidget( "instance" ), this, "instace stored in .data()" );
};
$.ui.testWidget( {}, elem[ 0 ] );
elem = $( "<div>" );
$.ui.testWidget.prototype._create = function() {
deepEqual( this.element[ 0 ], elem[ 0 ], "from jQuery object" );
- deepEqual( elem.data( "ui-testWidget" ), this, "instace stored in .data()" );
+ deepEqual( elem.testWidget( "instance" ), this, "instace stored in .data()" );
};
$.ui.testWidget( {}, elem );
@@ -72,7 +72,7 @@ test( "element normalization", function() {
.appendTo( "#qunit-fixture" );
$.ui.testWidget.prototype._create = function() {
deepEqual( this.element[ 0 ], elem[ 0 ], "from selector" );
- deepEqual( elem.data( "ui-testWidget" ), this, "instace stored in .data()" );
+ deepEqual( elem.testWidget( "instance" ), this, "instace stored in .data()" );
};
$.ui.testWidget( {}, "#element-normalization-selector" );
@@ -133,7 +133,7 @@ test( "jQuery usage", function() {
.testWidget();
shouldCreate = false;
- instance = elem.data( "ui-testWidget" );
+ instance = elem.testWidget( "instance" );
equal( typeof instance, "object", "instance stored in .data(pluginName)" );
equal( instance.element[0], elem[0], "element stored on widget" );
ret = elem.testWidget( "methodWithParams", "value1", "value2" );
@@ -149,7 +149,7 @@ test( "jQuery usage", function() {
equal( ret.end(), elem, "stack preserved" );
elem.testWidget( "destroy" );
- equal( elem.data( "ui-testWidget" ), null );
+ equal( elem.testWidget( "instance" ), null );
});
test( "direct usage", function() {
@@ -185,7 +185,7 @@ test( "direct usage", function() {
instance = new $.ui.testWidget( {}, elem );
shouldCreate = false;
- equal( $( elem ).data( "ui-testWidget" ), instance,
+ equal( $( elem ).testWidget( "instance" ), instance,
"instance stored in .data(pluginName)" );
equal( instance.element[ 0 ], elem, "element stored on widget" );
@@ -405,7 +405,7 @@ test( "._super()", function() {
}
});
- instance = $( "<div>" ).testWidget3().data( "ui-testWidget3" );
+ instance = $( "<div>" ).testWidget3().testWidget3( "instance" );
instance.method( 5 );
delete $.ui.testWidget3;
delete $.ui.testWidget2;
@@ -442,7 +442,7 @@ test( "._superApply()", function() {
}
});
- instance = $( "<div>" ).testWidget3().data( "ui-testWidget3" );
+ instance = $( "<div>" ).testWidget3().testWidget3( "instance" );
instance.method( 5, 10 );
delete $.ui.testWidget3;
delete $.ui.testWidget2;
@@ -560,7 +560,7 @@ test( ".option() - deep option setter", function() {
$.widget( "ui.testWidget", {} );
var div = $( "<div>" ).testWidget();
function deepOption( from, to, msg ) {
- div.data( "ui-testWidget" ).options.foo = from;
+ div.testWidget( "instance" ).options.foo = from;
$.ui.testWidget.prototype._setOption = function( key, value ) {
deepEqual( key, "foo", msg + ": key" );
deepEqual( value, to, msg + ": value" );
@@ -625,6 +625,20 @@ test( ".widget() - overriden", function() {
deepEqual( wrapper[0], $( "<div>" ).testWidget().testWidget( "widget" )[0] );
});
+test( ".instance()", function() {
+ expect( 2 );
+ var div;
+
+ $.widget( "ui.testWidget", {
+ _create: function() {}
+ });
+
+ div = $( "<div>" );
+ equal( div.testWidget( "instance" ), undefined );
+ div.testWidget();
+ equal( div.testWidget( "instance" ), div.testWidget( "instance" ) );
+});
+
test( "._on() to element (default)", function() {
expect( 12 );
var that, widget;
@@ -840,7 +854,7 @@ test( "_on() to common element", function() {
ok( true, "handler triggered" );
}
});
- var widget = $( "#widget" ).testWidget().data( "ui-testWidget" );
+ var widget = $( "#widget" ).testWidget().testWidget( "instance" );
$( "#widget-wrapper" ).testWidget();
widget.destroy();
$( document ).trigger( "customevent" );
@@ -852,7 +866,7 @@ test( "_off() - single event", function() {
$.widget( "ui.testWidget", {} );
var shouldTriggerWidget, shouldTriggerOther,
element = $( "#widget" ),
- widget = element.testWidget().data( "ui-testWidget" );
+ widget = element.testWidget().testWidget( "instance" );
widget._on( element, { foo: function() {
ok( shouldTriggerWidget, "foo called from _on" );
}});
@@ -873,7 +887,7 @@ test( "_off() - multiple events", function() {
$.widget( "ui.testWidget", {} );
var shouldTriggerWidget, shouldTriggerOther,
element = $( "#widget" ),
- widget = element.testWidget().data( "ui-testWidget" );
+ widget = element.testWidget().testWidget( "instance" );
widget._on( element, {
foo: function() {
ok( shouldTriggerWidget, "foo called from _on" );
@@ -901,7 +915,7 @@ test( "_off() - all events", function() {
$.widget( "ui.testWidget", {} );
var shouldTriggerWidget, shouldTriggerOther,
element = $( "#widget" ),
- widget = element.testWidget().data( "ui-testWidget" );
+ widget = element.testWidget().testWidget( "instance" );
widget._on( element, {
foo: function() {
ok( shouldTriggerWidget, "foo called from _on" );
@@ -1007,7 +1021,7 @@ test( "._trigger() - no event, no ui", function() {
deepEqual( ui, {}, "empty ui hash passed" );
handlers.push( this );
});
- deepEqual( $( "#widget" ).data( "ui-testWidget" )._trigger( "foo" ), true,
+ deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), true,
"_trigger returns true when event is not cancelled" );
deepEqual( handlers, [
$( "#widget" )[ 0 ],
@@ -1035,7 +1049,7 @@ test( "._trigger() - cancelled event", function() {
ok( true, "event was triggered" );
return false;
});
- deepEqual( $( "#widget" ).data( "ui-testWidget" )._trigger( "foo" ), false,
+ deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), false,
"_trigger returns false when event is cancelled" );
});
@@ -1050,7 +1064,7 @@ test( "._trigger() - cancelled callback", function() {
return false;
}
});
- deepEqual( $( "#widget" ).data( "ui-testWidget" )._trigger( "foo" ), false,
+ deepEqual( $( "#widget" ).testWidget( "instance" )._trigger( "foo" ), false,
"_trigger returns false when callback returns false" );
});
@@ -1384,7 +1398,7 @@ asyncTest( "_delay", function() {
});
test( "$.widget.bridge()", function() {
- expect( 9 );
+ expect( 10 );
var instance, ret,
elem = $( "<div>" );
@@ -1412,6 +1426,7 @@ test( "$.widget.bridge()", function() {
strictEqual( elem.testWidget({ foo: "bar" }), elem, "plugin returns original jQuery object" );
instance = elem.data( "testWidget" );
equal( typeof instance, "object", "instance stored in .data(pluginName)" );
+ equal( typeof elem.testWidget( "instance" ), "object", "also retrievable via instance method" );
ret = elem.testWidget( "method", "value1" );
equal( ret, elem, "jQuery object returned from method call" );