Skip to content
Permalink
Browse files

Draggable: Convert tests to new infrastructure

Ref #10119
Ref gh-1528
  • Loading branch information...
scottgonzalez committed Apr 6, 2015
1 parent 9fb04e4 commit fbc55446fbc397f7f176fd907fd5da5ff3d3abad
@@ -4,94 +4,65 @@
<meta charset="utf-8">
<title>jQuery UI Draggable Test Suite</title>

<script src="../../jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">

<script src="../../lib/css.js" data-modules="core"></script>
<script src="../../lib/bootstrap.js" data-widget="draggable"></script>
<style>
#main {
width: 1000px;
height: 1000px;
overflow: scroll;
overflow-x: scroll;
overflow-y: scroll;
position: relative;
left: 0;
top: 0;
}
#main-forceScrollable {
position: absolute;
left: 0;
top: 0;
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 {
position: absolute;
left: 0;
top: 0;
width: 1300px;
height: 1300px;
}
/* See #9077 */
#draggable3, #draggable4 {
z-index: 100;
}
.sortable {
position: relative;
top: 8000px;
left: 10px;
width: 300px;
padding: 0;
margin: 0;
border: 0;
}
.sortable li {
height: 100px;
padding: 0;
margin: 0;
border: 0;
list-style: none;
display: inline-block;
}
#main {
width: 1000px;
height: 1000px;
overflow: scroll;
overflow-x: scroll;
overflow-y: scroll;
position: relative;
left: 0;
top: 0;
}
#main-forceScrollable {
position: absolute;
left: 0;
top: 0;
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 {
position: absolute;
left: 0;
top: 0;
width: 1300px;
height: 1300px;
}
/* See #9077 */
#draggable3, #draggable4 {
z-index: 100;
}
.sortable {
position: relative;
top: 8000px;
left: 10px;
width: 300px;
padding: 0;
margin: 0;
border: 0;
}
.sortable li {
height: 100px;
padding: 0;
margin: 0;
border: 0;
list-style: none;
display: inline-block;
}
</style>

<script src="../../../external/qunit/qunit.js"></script>
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
<script src="../testsuite.js"></script>
<script src="../../../external/qunit-assert-classes/qunit-assert-classes.js"></script>
<script>
TestHelpers.loadResources({
css: [ "core" ],
js: [
"ui/core.js",
"ui/widget.js",
"ui/mouse.js",
"ui/resizable.js",
"ui/draggable.js",
"ui/droppable.js",
"ui/sortable.js"
]
});
</script>

<script src="draggable_common.js"></script>
<script src="draggable_core.js"></script>
<script src="draggable_events.js"></script>
<script src="draggable_methods.js"></script>
<script src="draggable_options.js"></script>
<script src="draggable_test_helpers.js"></script>

<script src="../swarminject.js"></script>
</head>
<body>

@@ -1,4 +1,9 @@
TestHelpers.commonWidgetTests( "draggable", {
define( [
"lib/common",
"ui/draggable"
], function( common ) {

common.testWidget( "draggable", {
defaults: {
appendTo: "parent",
axis: false,
@@ -39,3 +44,5 @@ TestHelpers.commonWidgetTests( "draggable", {
stop: null
}
});

} );
@@ -1,8 +1,11 @@
/*
* draggable_core.js
*/

(function( $ ) {
define( [
"jquery",
"lib/helper",
"./draggable_test_helpers",
"ui/draggable",
"ui/droppable",
"ui/resizable"
], function( $, testHelpers, draggableTestHelpers ) {

module( "draggable: core" );

@@ -44,12 +47,12 @@ test( "element types", function( assert ) {

test( "No options, relative", function() {
expect( 2 );
TestHelpers.draggable.shouldMove( $( "#draggable1" ).draggable(), "no options, relative" );
draggableTestHelpers.shouldMove( $( "#draggable1" ).draggable(), "no options, relative" );
});

test( "No options, absolute", function() {
expect( 2 );
TestHelpers.draggable.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" );
draggableTestHelpers.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" );
});

test( "resizable handle with complex markup (#8756 / #8757)", function() {
@@ -92,7 +95,7 @@ test( "#8269: Removing draggable element on drop", function() {
});

// Support: Opera 12.10, Safari 5.1, jQuery <1.8
if ( TestHelpers.draggable.unreliableContains ) {
if ( draggableTestHelpers.unreliableContains ) {
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" );
} else {
@@ -118,7 +121,7 @@ test( "Stray mousemove after mousedown still drags", function() {
$( document ).simulate( "mousemove", { button: -1 });
});

TestHelpers.draggable.shouldMove( element, "element is draggable" );
draggableTestHelpers.shouldMove( element, "element is draggable" );
});

test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() {
@@ -138,7 +141,7 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f
oldOverflowY = $( "html" ).css( "overflow-y" ),
oldOverflowX = $( "html" ).css( "overflow-x" );

TestHelpers.forceScrollableWindow();
testHelpers.forceScrollableWindow();

$( "html" )
.css( "overflow-y", "scroll" )
@@ -164,7 +167,7 @@ test( "#9315: jumps down with offset of scrollbar", function() {
}
});

TestHelpers.forceScrollableWindow();
testHelpers.forceScrollableWindow();

$( "html" ).scrollTop( 300 ).scrollLeft( 300 );

@@ -198,7 +201,7 @@ test( "scroll offset with fixed ancestors", function() {
}
});

TestHelpers.forceScrollableWindow();
testHelpers.forceScrollableWindow();

$( "#wrapper" ).css( "position", "fixed" );
$( "#wrapper2" ).css( "position", "absolute" );
@@ -269,8 +272,8 @@ test( "#5727: draggable from iframe", function() {
equal( draggable1.closest( iframeBody ).length, 1 );

// TODO: fix draggable within an IFRAME to fire events on the element properly
// and these TestHelpers.draggable.shouldMove relies on events for testing
//TestHelpers.draggable.shouldMove( draggable1, "draggable from an iframe" );
// and these draggableTestHelpers.shouldMove relies on events for testing
//draggableTestHelpers.shouldMove( draggable1, "draggable from an iframe" );
});

test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function() {
@@ -282,7 +285,7 @@ test( "#8399: A draggable should become the active element after you are finishe
notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" );
});

TestHelpers.draggable.move( element, 50, 50 );
draggableTestHelpers.move( element, 50, 50 );

strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" );
});
@@ -293,16 +296,16 @@ asyncTest( "blur behavior", function() {
var element = $( "#draggable1" ).draggable(),
focusElement = $( "<div tabindex='1'></div>" ).appendTo( element );

TestHelpers.onFocus( focusElement, function() {
testHelpers.onFocus( focusElement, function() {
strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused before mousing down on a draggable" );

TestHelpers.draggable.move( focusElement, 1, 1 );
draggableTestHelpers.move( focusElement, 1, 1 );

// http://bugs.jqueryui.com/ticket/10527
// Draggable: Can't select option in modal dialog (IE8)
strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused after mousing down on itself" );

TestHelpers.draggable.move( element, 50, 50 );
draggableTestHelpers.move( element, 50, 50 );

// http://bugs.jqueryui.com/ticket/4261
// active element should blur when mousing down on a draggable
@@ -341,4 +344,4 @@ test( "ui-draggable-handle managed correctly in nested draggables", function( as
assert.hasClasses( child, "ui-draggable-handle", "child retains class name on destroy" );
});

})( jQuery );
} );
@@ -1,7 +1,7 @@
/*
* draggable_events.js
*/
(function( $ ) {
define( [
"jquery",
"ui/draggable"
], function( $ ) {

var element;

@@ -161,4 +161,4 @@ test( "position and offset in hash is consistent between start, drag, and stop",
deepEqual( dragOffset, stopOffset, "drag offset equals stop offset" );
});

})( jQuery );
} );
@@ -1,7 +1,8 @@
/*
* draggable_methods.js
*/
(function( $ ) {
define( [
"jquery",
"./draggable_test_helpers",
"ui/draggable"
], function( $, draggableTestHelpers ) {

var element;

@@ -54,19 +55,19 @@ test( "enable", function() {
expect( 11 );

element.draggable({ disabled: true });
TestHelpers.draggable.shouldNotDrag( element, ".draggable({ disabled: true })" );
draggableTestHelpers.shouldNotDrag( element, ".draggable({ disabled: true })" );

element.draggable("enable");
TestHelpers.draggable.shouldMove( element, ".draggable('enable')" );
draggableTestHelpers.shouldMove( element, ".draggable('enable')" );
equal( element.draggable( "option", "disabled" ), false, "disabled option getter" );

element.draggable("destroy");
element.draggable({ disabled: true });
TestHelpers.draggable.shouldNotDrag( element, ".draggable({ disabled: true })" );
draggableTestHelpers.shouldNotDrag( element, ".draggable({ disabled: true })" );

element.draggable( "option", "disabled", false );
equal(element.draggable( "option", "disabled" ), false, "disabled option setter" );
TestHelpers.draggable.shouldMove( element, ".draggable('option', 'disabled', false)" );
draggableTestHelpers.shouldMove( element, ".draggable('option', 'disabled', false)" );

var expected = element.draggable(),
actual = expected.draggable("enable");
@@ -77,19 +78,19 @@ test( "disable", function( assert ) {
expect( 14 );

element = $( "#draggable2" ).draggable({ disabled: false });
TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" );
draggableTestHelpers.shouldMove( element, ".draggable({ disabled: false })" );

element.draggable( "disable" );
TestHelpers.draggable.shouldNotDrag( element, ".draggable('disable')" );
draggableTestHelpers.shouldNotDrag( element, ".draggable('disable')" );
equal( element.draggable( "option", "disabled" ), true, "disabled option getter" );

element.draggable( "destroy" );
element.draggable({ disabled: false });
TestHelpers.draggable.shouldMove( element, ".draggable({ disabled: false })" );
draggableTestHelpers.shouldMove( element, ".draggable({ disabled: false })" );

element.draggable( "option", "disabled", true );
equal( element.draggable( "option", "disabled" ), true, "disabled option setter" );
TestHelpers.draggable.shouldNotDrag( element, ".draggable('option', 'disabled', true)" );
draggableTestHelpers.shouldNotDrag( element, ".draggable('option', 'disabled', true)" );

assert.lacksClasses( element.draggable( "widget" ), "ui-state-disabled" );
ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" );
@@ -100,4 +101,4 @@ test( "disable", function( assert ) {
equal( actual, expected, "disable is chainable" );
});

})( jQuery );
} );

0 comments on commit fbc5544

Please sign in to comment.
You can’t perform that action at this time.