aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2013-11-13 19:45:56 +0100
committerFelix Nagel <info@felixnagel.com>2013-11-13 19:45:56 +0100
commitab2219b6ac3dbab58885a0bd2aaac01c4bcc1c2f (patch)
treededf39afe3330bae4eec603297432d972e5bcfc1 /tests
parenta6c5f58d8243b39c6cd57b76ffb0776adfcc8b1c (diff)
parent14782c04e2201c53e3ecb80b086f1a4c27aa991d (diff)
downloadjquery-ui-ab2219b6ac3dbab58885a0bd2aaac01c4bcc1c2f.tar.gz
jquery-ui-ab2219b6ac3dbab58885a0bd2aaac01c4bcc1c2f.zip
Merge branch 'master' into selectmenu
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/accordion/accordion_core.js12
-rw-r--r--tests/unit/draggable/draggable.html44
-rw-r--r--tests/unit/draggable/draggable_options.js388
-rw-r--r--tests/unit/draggable/draggable_test_helpers.js20
-rw-r--r--tests/unit/droppable/droppable_options.js46
-rw-r--r--tests/unit/sortable/sortable.html12
-rw-r--r--tests/unit/sortable/sortable_core.js18
-rw-r--r--tests/unit/tabs/tabs_core.js2
8 files changed, 183 insertions, 359 deletions
diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js
index 101cb83b1..8e0175aeb 100644
--- a/tests/unit/accordion/accordion_core.js
+++ b/tests/unit/accordion/accordion_core.js
@@ -46,29 +46,29 @@ test( "accessibility", function () {
equal( headers.eq( 1 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
- equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" );
+ equal( headers.eq( 1 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 0 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
- equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
+ equal( headers.eq( 0 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
- equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
+ equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
element.accordion( "option", "active", 0 );
equal( headers.eq( 0 ).attr( "tabindex" ), 0, "active header has tabindex=0" );
equal( headers.eq( 0 ).attr( "aria-selected" ), "true", "active tab has aria-selected=true" );
- equal( headers.eq( 0 ).next().attr( "aria-expanded" ), "true", "active tabpanel has aria-expanded=true" );
+ equal( headers.eq( 0 ).attr( "aria-expanded" ), "true", "active tab has aria-expanded=true" );
equal( headers.eq( 0 ).next().attr( "aria-hidden" ), "false", "active tabpanel has aria-hidden=false" );
equal( headers.eq( 1 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 1 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
- equal( headers.eq( 1 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
+ equal( headers.eq( 1 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 1 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
equal( headers.eq( 2 ).attr( "tabindex" ), -1, "inactive header has tabindex=-1" );
equal( headers.eq( 2 ).attr( "aria-selected" ), "false", "inactive tab has aria-selected=false" );
- equal( headers.eq( 2 ).next().attr( "aria-expanded" ), "false", "inactive tabpanel has aria-expanded=false" );
+ equal( headers.eq( 2 ).attr( "aria-expanded" ), "false", "inactive tab has aria-expanded=false" );
equal( headers.eq( 2 ).next().attr( "aria-hidden" ), "true", "inactive tabpanel has aria-hidden=true" );
});
diff --git a/tests/unit/draggable/draggable.html b/tests/unit/draggable/draggable.html
index 17f9745a6..dd284f280 100644
--- a/tests/unit/draggable/draggable.html
+++ b/tests/unit/draggable/draggable.html
@@ -8,8 +8,38 @@
<link rel="stylesheet" href="../../../external/qunit.css">
<style>
+ #main {
+ width: 1000px;
+ height: 1000px;
+ overflow: scroll;
+ overflow-x: scroll;
+ overflow-y: scroll;
+ position: relative;
+ left: 0;
+ top: 0;
+ }
+ #main-forceScrollable {
+ width: 1100px;
+ height: 1100px;
+ }
+ #scrollParent {
+ width: 1200px;
+ height: 1200px;
+ position: relative;
+ left: 0;
+ top: 0;
+ overflow: hidden;
+ overflow-x: hidden;
+ overflow-y: hidden;
+ }
+ #scrollParent-forceScrollable {
+ width: 1300px;
+ height: 1300px;
+ }
/* See #9077 */
- #draggable3, #draggable4 { z-index: 100; }
+ #draggable3, #draggable4 {
+ z-index: 100;
+ }
</style>
<script src="../../../external/qunit.js"></script>
@@ -46,10 +76,14 @@
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
- <div id="main">
- <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><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 id="scrollParent">
+ <div id="main">
+ <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><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 id="main-forceScrollable"></div>
+ </div>
+ <div id="scrollParent-forceScrollable"></div>
</div>
<div style="width: 1px; height: 1000px;"></div>
<div style="position: absolute; width: 1px; height: 2000px;"></div>
diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js
index 8a7a28735..ea52eb299 100644
--- a/tests/unit/draggable/draggable_options.js
+++ b/tests/unit/draggable/draggable_options.js
@@ -158,7 +158,7 @@ test( "axis, default, switching after initialization", function() {
test( "{ cancel: 'input,textarea,button,select,option' }, default", function() {
expect( 2 );
- $( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#main" );
+ $( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" });
TestHelpers.draggable.shouldMove( element, "cancel: default, element dragged" );
@@ -230,7 +230,7 @@ test( "{ cancel: Selectors }, matching parent selector", function() {
test( "cancelement, default, switching after initialization", function() {
expect( 2 );
- $( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#main" );
+ $( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" );
var input = $( "#draggable-option-cancel-default input" ),
element = $( "#draggable-option-cancel-default" ).draggable();
@@ -346,7 +346,7 @@ test( "{ containment: 'parent' }, absolute", function() {
test( "containment, account for border", function() {
expect( 2 );
- var el = $("#draggable1").appendTo("#main"),
+ var el = $( "#draggable1" ).appendTo( "#scrollParent" ),
parent = el.parent().css({
height: "100px",
width: "100px",
@@ -368,9 +368,9 @@ test( "containment, account for border", function() {
dy: 100
});
- equal( el.offset().top, parentBottom - parentBorderBottom - el.height(),
+ closeEnough( el.offset().top, parentBottom - parentBorderBottom - el.height(), 1,
"The draggable should be on top of its parent's bottom border" );
- equal( el.offset().left, parentRight - parentBorderRight - el.width(),
+ closeEnough( el.offset().left, parentRight - parentBorderRight - el.width(), 1,
"The draggable should be to the right of its parent's right border" );
});
@@ -381,13 +381,7 @@ test( "containment, default, switching after initialization", function() {
TestHelpers.draggable.testDrag( element, element, -100, -100, -100, -100, "containment: default" );
- element.draggable( "option", "containment", "parent" )
- .css({
- top: 0,
- left: 0
- })
- .appendTo( $( "#main" ) );
-
+ element.draggable( "option", "containment", "parent" ).css({ top: 0, left: 0 });
TestHelpers.draggable.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" );
element.draggable( "option", "containment", false );
@@ -666,332 +660,66 @@ test( "helper, default, switching after initialization", function() {
TestHelpers.draggable.shouldMove( element, "helper: default" );
element.draggable( "option", "helper", "clone" );
- TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone" );
+ TestHelpers.draggable.shouldMove( element, "helper: clone" );
element.draggable( "option", "helper", "original" );
TestHelpers.draggable.shouldMove( element, "helper: original" );
});
-test( "{ helper: 'clone' }, relative", function() {
- expect( 2 );
-
- var element = $( "#draggable1" ).draggable({ helper: "clone" });
- TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone relative" );
-});
-
-test( "{ helper: 'clone' }, absolute", function() {
- expect( 2 );
-
- var element = $( "#draggable2" ).draggable({ helper: "clone" });
- TestHelpers.draggable.shouldMovePositionButNotOffset( element, "helper: clone absolute" );
-});
-
-test( "{ helper: 'original' }, relative, with scroll offset on parent", function() {
- expect( 6 );
-
- var element = $( "#draggable1" ).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( "#main" );
-});
-
-test( "{ helper: 'original' }, relative, with scroll offset on root", function() {
- expect( 6 );
-
- var element = $( "#draggable1" ).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( document );
-});
-
-test( "{ helper: 'original' }, relative, with scroll offset on root and parent", function() {
- expect( 6 );
-
- var element = $( "#draggable1" ).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( "#main" );
- TestHelpers.draggable.restoreScroll( document );
-});
-
-test( "{ helper: 'original' }, absolute, with scroll offset on parent", function() {
- expect( 6 );
-
- var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( "#main" );
-});
-
-test( "{ helper: 'original' }, absolute, with scroll offset on root", function() {
- expect( 6 );
-
- var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( document );
-});
-
-test( "{ helper: 'original' }, absolute, with scroll offset on root and parent", function() {
- expect( 6 );
-
- var element = $( "#draggable1" ).css({ position: "absolute", top: 0, left: 0 }).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( "#main" );
- TestHelpers.draggable.restoreScroll( document );
-});
-
-test( "{ helper: 'original' }, fixed, with scroll offset on parent", function() {
- expect( 4 );
-
- var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( "#main" );
- // TODO: investigate these failure in PhantomJS
- //TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( "#main" );
-});
-
-test( "{ helper: 'original' }, fixed, with scroll offset on root", function() {
- expect( 4 );
-
- var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( document );
- // TODO: investigate these failure in PhantomJS
- //TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( document );
-});
-
-test( "{ helper: 'original' }, fixed, with scroll offset on root and parent", function() {
- expect( 4 );
-
- var element = $( "#draggable1" ).css({ position: "fixed", top: 0, left: 0 }).draggable({ helper: "original" });
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "relative" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.testScroll( element, "static" );
-
- TestHelpers.draggable.setScroll( "#main" );
- TestHelpers.draggable.setScroll( document );
- // TODO: investigate these failure in PhantomJS
- //TestHelpers.draggable.testScroll( element, "absolute" );
-
- TestHelpers.draggable.restoreScroll( "#main" );
- TestHelpers.draggable.restoreScroll( document );
-});
-
-test( "{ helper: 'clone' }, absolute", function() {
- expect( 1 );
-
- var helperOffset = null,
- origOffset = $( "#draggable1" ).offset(),
- element = $( "#draggable1" ).draggable({ helper: "clone", drag: function( event, ui) {
- helperOffset = ui.helper.offset();
- } });
-
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-});
-
-test( "{ helper: 'clone' }, absolute with scroll offset on parent", function() {
- expect( 3 );
-
- TestHelpers.draggable.setScroll( "#main" );
- var helperOffset = null,
- origOffset = null,
- element = $( "#draggable1" ).draggable({
- helper: "clone",
- drag: function( event, ui) {
- helperOffset = ui.helper.offset();
- }
- });
-
- $( "#main" ).css( "position", "relative" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-
- $( "#main" ).css( "position", "static" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-
- $( "#main" ).css( "position", "absolute" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-
- TestHelpers.draggable.restoreScroll( "#main" );
-});
-
-test( "{ helper: 'clone' }, absolute with scroll offset on root", function() {
- expect( 3 );
-
- TestHelpers.draggable.setScroll( document );
- var helperOffset = null,
- origOffset = null,
- element = $( "#draggable1" ).draggable({
- helper: "clone",
- drag: function( event, ui) {
- helperOffset = ui.helper.offset();
- }
- });
-
- $( "#main" ).css( "position", "relative" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-
- $( "#main" ).css( "position", "static" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-
- $( "#main" ).css( "position", "absolute" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
+/* jshint loopfunc: true */
+(function(){
+ var k, l, m,
+ scrollElements = {
+ "no elements": [],
+ "parent": [ "#main" ],
+ "root": [ document ],
+ "parent and root": [ "#main", document ],
+ "grandparent": [ "#scrollParent" ]
+ },
+ positions = [ "absolute", "fixed", "relative", "static" ],
+ helpers = [ "original", "clone" ],
+ scrollPositions = [ "relative", "static", "absolute", "fixed" ];
+
+ for ( m = 0 ; m < helpers.length; m++ ) {
+ for ( l = 0; l < positions.length; l++ ) {
+ for ( k in scrollElements ) {
+ (function( position, helper, scrollElements, scrollElementsTitle ){
+ test( "{ helper: '" + helper + "' }, " + position + ", with scroll offset on " + scrollElementsTitle, function() {
+ expect( 8 );
+ var i, j,
+ element = $( "#draggable1" ).css({ position: position, top: 0, left: 0 }).draggable({
+ helper: helper,
+ scroll: false
+ });
+
+ if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
+ TestHelpers.draggable.setScrollable( "#main", false );
+ TestHelpers.draggable.setScrollable( "#scrollParent", true );
+ }
- TestHelpers.draggable.restoreScroll( document );
-});
+ for ( j = 0; j < scrollPositions.length; j++ ) {
+ for ( i = 0; i < scrollElements.length; i++ ) {
+ TestHelpers.draggable.setScroll( scrollElements[ i ] );
+ }
-test( "{ helper: 'clone' }, absolute with scroll offset on root and parent", function() {
- expect( 3 );
+ TestHelpers.draggable.testScroll( element, scrollPositions[ j ] );
- TestHelpers.draggable.setScroll( document );
- TestHelpers.draggable.setScroll( "#main" );
+ for ( i = 0; i < scrollElements.length; i++ ) {
+ TestHelpers.draggable.restoreScroll( scrollElements[ i ] );
+ }
+ }
- var helperOffset = null,
- origOffset = null,
- element = $( "#draggable1" ).draggable({
- helper: "clone",
- drag: function( event, ui) {
- helperOffset = ui.helper.offset();
+ if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) {
+ TestHelpers.draggable.setScrollable( "#main", true );
+ TestHelpers.draggable.setScrollable( "#scrollParent", false );
+ }
+ });
+ })( positions[ l ], helpers[ m ], scrollElements[ k ], k );
}
- });
-
- $( "#main" ).css( "position", "relative" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-
- $( "#main" ).css( "position", "static" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-
- $( "#main" ).css( "position", "absolute" );
- origOffset = $( "#draggable1" ).offset();
- element.simulate( "drag", {
- dx: 1,
- dy: 1
- });
- deepEqual({ top: helperOffset.top - 1, left: helperOffset.left - 1 }, origOffset, "dragged[1, 1]" );
-
- TestHelpers.draggable.restoreScroll( document );
- TestHelpers.draggable.restoreScroll( "#main" );
-});
+ }
+ }
+})();
+/* jshint loopfunc: false */
test( "{ opacity: 0.5 }", function() {
expect( 1 );
@@ -1098,8 +826,10 @@ test( "scope", function() {
test( "scroll, scrollSensitivity, and scrollSpeed", function() {
expect( 2 );
+ TestHelpers.draggable.setScrollable( "#main", false );
+
var viewportHeight = $( window ).height(),
- element = $( "#draggable1" ).draggable({ scroll: true }),
+ element = $( "#draggable1" ).draggable({ scroll: true }).appendTo( "#qunit-fixture" ),
scrollSensitivity = element.draggable( "option", "scrollSensitivity" ),
scrollSpeed = element.draggable( "option", "scrollSpeed" );
diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js
index 2edf7452f..0b533a4e1 100644
--- a/tests/unit/draggable/draggable_test_helpers.js
+++ b/tests/unit/draggable/draggable_test_helpers.js
@@ -20,8 +20,8 @@ TestHelpers.draggable = {
var offsetBefore = el.offset(),
offsetExpected = { left: offsetBefore.left + expectedDX, top: offsetBefore.top + expectedDY };
- $( el ).one( "dragstop", function() {
- deepEqual( el.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
+ $( el ).one( "dragstop", function( event, ui ) {
+ deepEqual( ui.helper.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg );
} );
},
testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) {
@@ -30,10 +30,7 @@ TestHelpers.draggable = {
$( handle ).simulate( "drag", {
dx: dx,
- dy: dy,
- // moves is 1 here because simulate currently fire events synchronously
- // so we can't faithfully test things that rely on a scroll event (which is async)
- moves: 1
+ dy: dy
});
},
shouldMovePositionButNotOffset: function( el, msg, handle ) {
@@ -43,10 +40,7 @@ TestHelpers.draggable = {
$( handle ).simulate( "drag", {
dx: 100,
- dy: 100,
- // moves is 1 here because simulate currently fire events synchronously
- // so we can't faithfully test things that rely on a scroll event (which is async)
- moves: 1
+ dy: 100
});
},
shouldMove: function( el, msg, handle ) {
@@ -68,9 +62,13 @@ TestHelpers.draggable = {
});
$( el ).unbind( "dragstop" );
},
+ setScrollable: function ( what, isScrollable ) {
+ var overflow = isScrollable ? "scroll" : "hidden";
+ $( what ).css({ overflow: overflow, overflowX: overflow, overflowY: overflow });
+ },
testScroll: function( el, position ) {
var oldPosition = $( "#main" ).css( "position" );
- $( "#main" ).css( "position", position);
+ $( "#main" ).css({ position: position, top: "0px", left: "0px" });
TestHelpers.draggable.shouldMove( el, position + " parent" );
$( "#main" ).css( "position", oldPosition );
},
diff --git a/tests/unit/droppable/droppable_options.js b/tests/unit/droppable/droppable_options.js
index c2ecdcfda..1d8f95da9 100644
--- a/tests/unit/droppable/droppable_options.js
+++ b/tests/unit/droppable/droppable_options.js
@@ -35,6 +35,48 @@ test("{ addClasses: false }", function() {
ok(!el.is(".ui-droppable"), "'ui-droppable' class not added");
el.droppable("destroy");
});
+
+test( "scope", function() {
+ expect( 4 );
+ var droppableOffset, draggableOffset, oldDraggableOffset, dx, dy,
+ draggable1 = $("<div></div>").appendTo( "#qunit-fixture" ).draggable({ revert: "invalid" }),
+ draggable2 = $("<div></div>").appendTo( "#qunit-fixture" ).droppable(),
+ droppable = $("<div></div>").appendTo( "#qunit-fixture" ).droppable(),
+ newScope = "test";
+
+ draggable1.draggable( "option", "scope", newScope );
+ droppable.droppable( "option", "scope", newScope );
+
+ // Test that droppable accepts draggable with new scope.
+ droppableOffset = droppable.offset();
+ draggableOffset = draggable1.offset();
+ dx = droppableOffset.left - draggableOffset.left;
+ dy = droppableOffset.top - draggableOffset.top;
+
+ draggable1.simulate( "drag", {
+ dx: dx,
+ dy: dy
+ });
+
+ draggableOffset = draggable1.offset();
+ equal( draggableOffset.left, droppableOffset.left );
+ equal( draggableOffset.top, droppableOffset.top );
+
+ // Test that droppable doesn't accept draggable with old scope.
+ draggableOffset = draggable2.offset();
+ dx = droppableOffset.left - draggableOffset.left;
+ dy = droppableOffset.top - draggableOffset.top;
+ oldDraggableOffset = draggableOffset;
+
+ draggable2.simulate( "drag", {
+ dx: dx,
+ dy: dy
+ });
+
+ draggableOffset = draggable2.offset();
+ equal( draggableOffset.left, oldDraggableOffset.left );
+ equal( draggableOffset.top, oldDraggableOffset.top );
+});
/*
test("greedy", function() {
ok(false, 'missing test - untested code is broken code');
@@ -44,10 +86,6 @@ test("hoverClass", function() {
ok(false, 'missing test - untested code is broken code');
});
-test("scope", function() {
- ok(false, 'missing test - untested code is broken code');
-});
-
test("tolerance, fit", function() {
ok(false, 'missing test - untested code is broken code');
});
diff --git a/tests/unit/sortable/sortable.html b/tests/unit/sortable/sortable.html
index 8e0bac501..b03c786e1 100644
--- a/tests/unit/sortable/sortable.html
+++ b/tests/unit/sortable/sortable.html
@@ -38,7 +38,7 @@
margin: 1px;
border-width: 0;
}
- #sortable li{
+ #sortable li, #sortable2 li{
padding: 0;
margin: 0;
border-width: 0;
@@ -58,7 +58,15 @@
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">
-<ul id="sortable">
+<ul id="sortable" class="connectWith">
+ <li>Item 1</li>
+ <li>Item 2</li>
+ <li>Item 3</li>
+ <li>Item 4</li>
+ <li>Item 5</li>
+</ul>
+
+<ul id="sortable2" class="connectWith">
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
diff --git a/tests/unit/sortable/sortable_core.js b/tests/unit/sortable/sortable_core.js
index 211f8ac95..18e7dae08 100644
--- a/tests/unit/sortable/sortable_core.js
+++ b/tests/unit/sortable/sortable_core.js
@@ -1,3 +1,19 @@
/*
* sortable_core.js
- */ \ No newline at end of file
+ */
+
+(function( $ ) {
+
+module( "sortable: core" );
+
+test( "#9314: Sortable: Items cannot be dragged directly into bottom position", function() {
+ expect( 1 );
+
+ var el = $( ".connectWith" ).sortable({
+ connectWith: ".connectWith"
+ });
+
+ TestHelpers.sortable.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" );
+});
+
+})( jQuery );
diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js
index cc4f0460c..945dfb1e4 100644
--- a/tests/unit/tabs/tabs_core.js
+++ b/tests/unit/tabs/tabs_core.js
@@ -67,7 +67,7 @@ test( "aria-controls", function() {
tabs = element.find( ".ui-tabs-nav li" );
equal( tabs.eq( 0 ).attr( "aria-controls" ), "colon:test" );
equal( tabs.eq( 1 ).attr( "aria-controls" ), "inline-style" );
- ok( /^ui-tabs-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" );
+ ok( /^ui-id-\d+$/.test( tabs.eq( 2 ).attr( "aria-controls" ) ), "generated id" );
equal( tabs.eq( 3 ).attr( "aria-controls" ), "custom-id" );
});