Resizable: Convert tests to new infrastructure

Ref #10119
Ref gh-1528
This commit is contained in:
Scott González 2015-04-06 14:33:25 -04:00
parent df3e8c4deb
commit 4e7407cd69
7 changed files with 121 additions and 133 deletions

View File

@ -4,33 +4,8 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>jQuery UI Resizable Test Suite</title> <title>jQuery UI Resizable Test Suite</title>
<script src="../../jquery.js"></script> <script src="../../lib/css.js" data-modules="core resizable"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"> <script src="../../lib/bootstrap.js" data-widget="resizable"></script>
<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", "resizable" ],
js: [
"ui/core.js",
"ui/widget.js",
"ui/mouse.js",
"ui/resizable.js"
]
});
</script>
<script src="resizable_common.js"></script>
<script src="resizable_core.js"></script>
<script src="resizable_events.js"></script>
<script src="resizable_methods.js"></script>
<script src="resizable_options.js"></script>
<script src="resizable_test_helpers.js"></script>
<script src="../swarminject.js"></script>
<style> <style>
#container { #container {
width: 300px; width: 300px;

View File

@ -1,4 +1,9 @@
TestHelpers.commonWidgetTests( "resizable", { define( [
"lib/common",
"ui/resizable"
], function( common ) {
common.testWidget( "resizable", {
defaults: { defaults: {
alsoResize: false, alsoResize: false,
animate: false, animate: false,
@ -31,3 +36,5 @@ TestHelpers.commonWidgetTests( "resizable", {
stop: null stop: null
} }
}); });
} );

View File

@ -1,8 +1,8 @@
/* define( [
* resizable_core.js "jquery",
*/ "./resizable_test_helpers",
"ui/resizable"
(function($) { ], function( $, resizableTestHelpers ) {
module("resizable: core"); module("resizable: core");
@ -30,10 +30,10 @@ test("n", function() {
var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, 0, -50); resizableTestHelpers.drag(handle, 0, -50);
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
TestHelpers.resizable.drag(handle, 0, 50); resizableTestHelpers.drag(handle, 0, 50);
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
equal( target[0].style.left, "", "left should not be modified" ); equal( target[0].style.left, "", "left should not be modified" );
@ -45,10 +45,10 @@ test("s", function() {
var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, 0, 50); resizableTestHelpers.drag(handle, 0, 50);
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
TestHelpers.resizable.drag(handle, 0, -50); resizableTestHelpers.drag(handle, 0, -50);
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
equal( target[0].style.top, "", "top should not be modified" ); equal( target[0].style.top, "", "top should not be modified" );
@ -61,10 +61,10 @@ test("e", function() {
var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, 50); resizableTestHelpers.drag(handle, 50);
equal( target.width(), 150, "compare width"); equal( target.width(), 150, "compare width");
TestHelpers.resizable.drag(handle, -50); resizableTestHelpers.drag(handle, -50);
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target[0].style.height, "", "height should not be modified" ); equal( target[0].style.height, "", "height should not be modified" );
@ -77,10 +77,10 @@ test("w", function() {
var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50); resizableTestHelpers.drag(handle, -50);
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
TestHelpers.resizable.drag(handle, 50); resizableTestHelpers.drag(handle, 50);
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target[0].style.height, "", "height should not be modified" ); equal( target[0].style.height, "", "height should not be modified" );
@ -92,11 +92,11 @@ test("ne", function() {
var handle = ".ui-resizable-ne", target = $("#resizable1").css({ overflow: "hidden" }).resizable({ handles: "all" }); var handle = ".ui-resizable-ne", target = $("#resizable1").css({ overflow: "hidden" }).resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50, -50); resizableTestHelpers.drag(handle, -50, -50);
equal( target.width(), 50, "compare width" ); equal( target.width(), 50, "compare width" );
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
@ -108,11 +108,11 @@ test("se", function() {
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
TestHelpers.resizable.drag(handle, -50, -50); resizableTestHelpers.drag(handle, -50, -50);
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
@ -125,11 +125,11 @@ test("sw", function() {
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50, -50); resizableTestHelpers.drag(handle, -50, -50);
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
equal( target.height(), 50, "compare height" ); equal( target.height(), 50, "compare height" );
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
@ -141,11 +141,11 @@ test("nw", function() {
var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50, -50); resizableTestHelpers.drag(handle, -50, -50);
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
equal( target.height(), 150, "compare height" ); equal( target.height(), 150, "compare height" );
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
}); });
@ -163,10 +163,10 @@ test("handle with complex markup (#8756)", function() {
var handle = ".ui-resizable-w div", target = $("#resizable1").resizable({ handles: "all" }); var handle = ".ui-resizable-w div", target = $("#resizable1").resizable({ handles: "all" });
TestHelpers.resizable.drag(handle, -50); resizableTestHelpers.drag(handle, -50);
equal( target.width(), 150, "compare width" ); equal( target.width(), 150, "compare width" );
TestHelpers.resizable.drag(handle, 50); resizableTestHelpers.drag(handle, 50);
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
}); });
@ -186,7 +186,7 @@ test("resizable accounts for scroll position correctly (#3815)", function() {
left = el.css("left"); left = el.css("left");
top = el.css("top"); top = el.css("top");
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
deepEqual( el.position(), position, "position stays the same when resized" ); deepEqual( el.position(), position, "position stays the same when resized" );
equal( el.css("left"), left, "css('left') stays the same when resized" ); equal( el.css("left"), left, "css('left') stays the same when resized" );
equal( el.css("top"), top, "css('top') stays the same when resized" ); equal( el.css("top"), top, "css('top') stays the same when resized" );
@ -203,7 +203,7 @@ test( "resizable stores correct size when using helper and grid (#9547)", functi
grid: [ 10, 10 ] grid: [ 10, 10 ]
}); });
TestHelpers.resizable.drag( handle, 1, 1 ); resizableTestHelpers.drag( handle, 1, 1 );
equal( target.width(), 100, "compare width" ); equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
}); });
@ -227,18 +227,18 @@ test( "nested resizable", function() {
innerHandle = $( "#inner > .ui-resizable-e" ); innerHandle = $( "#inner > .ui-resizable-e" );
outerHandle = $( "#outer > .ui-resizable-e" ); outerHandle = $( "#outer > .ui-resizable-e" );
TestHelpers.resizable.drag( innerHandle, 10 ); resizableTestHelpers.drag( innerHandle, 10 );
equal( inner.width(), 40, "compare width of inner element" ); equal( inner.width(), 40, "compare width of inner element" );
TestHelpers.resizable.drag( innerHandle, -10 ); resizableTestHelpers.drag( innerHandle, -10 );
equal( inner.width(), 30, "compare width of inner element" ); equal( inner.width(), 30, "compare width of inner element" );
TestHelpers.resizable.drag( outerHandle, 10 ); resizableTestHelpers.drag( outerHandle, 10 );
equal( outer.width(), 60, "compare width of outer element" ); equal( outer.width(), 60, "compare width of outer element" );
TestHelpers.resizable.drag( outerHandle, -10 ); resizableTestHelpers.drag( outerHandle, -10 );
equal( outer.width(), 50, "compare width of outer element" ); equal( outer.width(), 50, "compare width of outer element" );
inner.remove(); inner.remove();
outer.remove(); outer.remove();
}); });
})(jQuery); } );

View File

@ -1,7 +1,8 @@
/* define( [
* resizable_events.js "jquery",
*/ "./resizable_test_helpers",
(function($) { "ui/resizable"
], function( $, resizableTestHelpers ) {
module("resizable: events"); module("resizable: events");
@ -23,7 +24,7 @@ test("start", function() {
} }
}); });
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
equal(count, 1, "start callback should happen exactly once"); equal(count, 1, "start callback should happen exactly once");
@ -54,7 +55,7 @@ test( "resize", function() {
} }
}); });
TestHelpers.resizable.drag( handle, 50, 50 ); resizableTestHelpers.drag( handle, 50, 50 );
equal( count, 2, "resize callback should happen exactly once per size adjustment" ); equal( count, 2, "resize callback should happen exactly once per size adjustment" );
@ -82,7 +83,7 @@ test( "resize (min/max dimensions)", function() {
} }
}); });
TestHelpers.resizable.drag( handle, -200, -200 ); resizableTestHelpers.drag( handle, -200, -200 );
equal( count, 1, "resize callback should happen exactly once per size adjustment" ); equal( count, 1, "resize callback should happen exactly once per size adjustment" );
@ -112,10 +113,10 @@ test( "resize (containment)", function() {
}); });
// Prove you can't resize outside containment by dragging southeast corner southeast // Prove you can't resize outside containment by dragging southeast corner southeast
TestHelpers.resizable.drag( handle, 100, 100 ); resizableTestHelpers.drag( handle, 100, 100 );
// Prove you can't resize outside containment by dragging southeast corner northwest // Prove you can't resize outside containment by dragging southeast corner northwest
TestHelpers.resizable.drag( handle, -200, -200 ); resizableTestHelpers.drag( handle, -200, -200 );
equal( count, 1, "resize callback should happen exactly once per size adjustment" ); equal( count, 1, "resize callback should happen exactly once per size adjustment" );
@ -140,7 +141,7 @@ test("resize (grid)", function() {
} }
}); });
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
equal(count, 1, "resize callback should happen exactly once per grid-unit size adjustment"); equal(count, 1, "resize callback should happen exactly once per grid-unit size adjustment");
@ -159,7 +160,7 @@ test( "resize, custom adjustment", function() {
} }
}); });
TestHelpers.resizable.drag( handle, 50, 50 ); resizableTestHelpers.drag( handle, 50, 50 );
equal( element.width(), 100, "resize event can control width" ); equal( element.width(), 100, "resize event can control width" );
equal( element.height(), 200, "resize event can control height" ); equal( element.height(), 200, "resize event can control height" );
@ -185,7 +186,7 @@ test("stop", function() {
} }
}); });
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
equal(count, 1, "stop callback should happen exactly once"); equal(count, 1, "stop callback should happen exactly once");
@ -230,7 +231,7 @@ test( "resize (containment) works with parent with negative offset", function()
widthBefore = target.width(); widthBefore = target.width();
TestHelpers.resizable.drag( handle, increaseWidthBy, 0 ); resizableTestHelpers.drag( handle, increaseWidthBy, 0 );
widthAfter = target.width(); widthAfter = target.width();
@ -238,4 +239,4 @@ test( "resize (containment) works with parent with negative offset", function()
}); });
})(jQuery); } );

View File

@ -1,7 +1,7 @@
/* define( [
* resizable_methods.js "jquery",
*/ "ui/resizable"
(function($) { ], function( $ ) {
module( "resizable: methods" ); module( "resizable: methods" );
@ -18,4 +18,4 @@ test( "disable", function( assert ) {
equal( chainable, element, "disable is chainable" ); equal( chainable, element, "disable is chainable" );
}); });
})(jQuery); } );

View File

@ -1,7 +1,8 @@
/* define( [
* resizable_options.js "jquery",
*/ "./resizable_test_helpers",
(function($) { "ui/resizable"
], function( $, resizableTestHelpers ) {
module("resizable: options"); module("resizable: options");
@ -19,7 +20,7 @@ test( "alsoResize", function() {
}), }),
handle = ".ui-resizable-e"; handle = ".ui-resizable-e";
TestHelpers.resizable.drag( handle, 80 ); resizableTestHelpers.drag( handle, 80 );
equal( element.width(), 180, "resizable width" ); equal( element.width(), 180, "resizable width" );
equal( other.width(), 130, "alsoResize width" ); equal( other.width(), 130, "alsoResize width" );
}); });
@ -29,11 +30,11 @@ test("aspectRatio: 'preserve' (e)", function() {
var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-e", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 80); resizableTestHelpers.drag(handle, 80);
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth");
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight");
TestHelpers.resizable.drag(handle, -130); resizableTestHelpers.drag(handle, -130);
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth");
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight");
}); });
@ -43,11 +44,11 @@ test("aspectRatio: 'preserve' (w)", function() {
var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-w", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, -80); resizableTestHelpers.drag(handle, -80);
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth");
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight");
TestHelpers.resizable.drag(handle, 130); resizableTestHelpers.drag(handle, 130);
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth");
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight");
}); });
@ -57,11 +58,11 @@ test("aspectRatio: 'preserve' (n)", function() {
var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 0, -80); resizableTestHelpers.drag(handle, 0, -80);
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth");
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight");
TestHelpers.resizable.drag(handle, 0, 80); resizableTestHelpers.drag(handle, 0, 80);
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth");
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight");
}); });
@ -71,11 +72,11 @@ test("aspectRatio: 'preserve' (s)", function() {
var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-s", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 0, 80); resizableTestHelpers.drag(handle, 0, 80);
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth");
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight");
TestHelpers.resizable.drag(handle, 0, -80); resizableTestHelpers.drag(handle, 0, -80);
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth");
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight");
}); });
@ -85,11 +86,11 @@ test("aspectRatio: 'preserve' (se)", function() {
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 80, 80); resizableTestHelpers.drag(handle, 80, 80);
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth");
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight");
TestHelpers.resizable.drag(handle, -80, -80); resizableTestHelpers.drag(handle, -80, -80);
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth");
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight");
}); });
@ -99,11 +100,11 @@ test("aspectRatio: 'preserve' (sw)", function() {
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, -80, 80); resizableTestHelpers.drag(handle, -80, 80);
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth");
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight");
TestHelpers.resizable.drag(handle, 80, -80); resizableTestHelpers.drag(handle, 80, -80);
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth");
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight");
}); });
@ -113,11 +114,11 @@ test("aspectRatio: 'preserve' (ne)", function() {
var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 }); var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
TestHelpers.resizable.drag(handle, 80, -80); resizableTestHelpers.drag(handle, 80, -80);
equal( target.width(), 130, "compare maxWidth"); equal( target.width(), 130, "compare maxWidth");
equal( target.height(), 130, "compare maxHeight"); equal( target.height(), 130, "compare maxHeight");
TestHelpers.resizable.drag(handle, -80, 80); resizableTestHelpers.drag(handle, -80, 80);
equal( target.width(), 70, "compare minWidth"); equal( target.width(), 70, "compare minWidth");
equal( target.height(), 70, "compare minHeight"); equal( target.height(), 70, "compare minHeight");
}); });
@ -137,7 +138,7 @@ test( "aspectRatio: Resizing can move objects", function() {
$( "#container" ).css({ width: 200, height: 300 }); $( "#container" ).css({ width: 200, height: 300 });
$( "#resizable1" ).css({ width: 100, height: 100, left: 75, top: 200 }); $( "#resizable1" ).css({ width: 100, height: 100, left: 75, top: 200 });
TestHelpers.resizable.drag( handleW, -20 ); resizableTestHelpers.drag( handleW, -20 );
equal( target.width(), 100, "compare width - no size change" ); equal( target.width(), 100, "compare width - no size change" );
equal( target.height(), 100, "compare height - no size change" ); equal( target.height(), 100, "compare height - no size change" );
equal( target.position().left, 75, "compare left - no movement" ); equal( target.position().left, 75, "compare left - no movement" );
@ -146,7 +147,7 @@ test( "aspectRatio: Resizing can move objects", function() {
$( "#container" ).css({ width: 200, height: 300, position: "absolute", left: 100, top: 100 }); $( "#container" ).css({ width: 200, height: 300, position: "absolute", left: 100, top: 100 });
$( "#resizable1" ).css({ width: 100, height: 100, left: 0, top: 0 }); $( "#resizable1" ).css({ width: 100, height: 100, left: 0, top: 0 });
TestHelpers.resizable.drag( handleNW, -20, -20 ); resizableTestHelpers.drag( handleNW, -20, -20 );
equal( target.width(), 100, "compare width - no size change" ); equal( target.width(), 100, "compare width - no size change" );
equal( target.height(), 100, "compare height - no size change" ); equal( target.height(), 100, "compare height - no size change" );
equal( target.position().left, 0, "compare left - no movement" ); equal( target.position().left, 0, "compare left - no movement" );
@ -160,11 +161,11 @@ test( "containment", function() {
containment: "#container" containment: "#container"
}); });
TestHelpers.resizable.drag( ".ui-resizable-se", 20, 30 ); resizableTestHelpers.drag( ".ui-resizable-se", 20, 30 );
equal( element.width(), 120, "unconstrained width within container" ); equal( element.width(), 120, "unconstrained width within container" );
equal( element.height(), 130, "unconstrained height within container" ); equal( element.height(), 130, "unconstrained height within container" );
TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 ); resizableTestHelpers.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "constrained width at containment edge" ); equal( element.width(), 300, "constrained width at containment edge" );
equal( element.height(), 200, "constrained height at containment edge" ); equal( element.height(), 200, "constrained height at containment edge" );
}); });
@ -179,10 +180,10 @@ test( "containment - not immediate parent", function() {
handles: "all" handles: "all"
}); });
TestHelpers.resizable.drag( ".ui-resizable-e", 300, 0 ); resizableTestHelpers.drag( ".ui-resizable-e", 300, 0 );
equal( element.width(), 400, "Relative, contained within container width" ); equal( element.width(), 400, "Relative, contained within container width" );
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 300 ); resizableTestHelpers.drag( ".ui-resizable-s", 0, 300 );
equal( element.height(), 400, "Relative, contained within container height" ); equal( element.height(), 400, "Relative, contained within container height" );
$( "#child" ).css( { left: 50, top: 50 } ); $( "#child" ).css( { left: 50, top: 50 } );
@ -194,10 +195,10 @@ test( "containment - not immediate parent", function() {
handles: "all" handles: "all"
}); });
TestHelpers.resizable.drag( ".ui-resizable-e", 400, 0 ); resizableTestHelpers.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 300, "Relative with Left, contained within container width" ); equal( element.width(), 300, "Relative with Left, contained within container width" );
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 400 ); resizableTestHelpers.drag( ".ui-resizable-s", 0, 400 );
equal( element.height(), 300, "Relative with Top, contained within container height" ); equal( element.height(), 300, "Relative with Top, contained within container height" );
}); });
@ -211,10 +212,10 @@ test( "containment - immediate parent", function() {
handles: "all" handles: "all"
}); });
TestHelpers.resizable.drag( ".ui-resizable-e", 400, 0 ); resizableTestHelpers.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 300, "Relative, contained within container width" ); equal( element.width(), 300, "Relative, contained within container width" );
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 400 ); resizableTestHelpers.drag( ".ui-resizable-s", 0, 400 );
equal( element.height(), 300, "Relative, contained within container height" ); equal( element.height(), 300, "Relative, contained within container height" );
$( "#child" ).css( { left: 50, top: 50 } ); $( "#child" ).css( { left: 50, top: 50 } );
@ -226,10 +227,10 @@ test( "containment - immediate parent", function() {
handles: "all" handles: "all"
}); });
TestHelpers.resizable.drag( ".ui-resizable-e", 400, 0 ); resizableTestHelpers.drag( ".ui-resizable-e", 400, 0 );
equal( element.width(), 250, "Relative with Left, contained within container width" ); equal( element.width(), 250, "Relative with Left, contained within container width" );
TestHelpers.resizable.drag( ".ui-resizable-s", 0, 400 ); resizableTestHelpers.drag( ".ui-resizable-s", 0, 400 );
equal( element.height(), 250, "Relative with Top, contained within container height" ); equal( element.height(), 250, "Relative with Top, contained within container height" );
}); });
@ -238,11 +239,11 @@ test("grid", function() {
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: [ 0, 20 ] }); var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: [ 0, 20 ] });
TestHelpers.resizable.drag(handle, 3, 9); resizableTestHelpers.drag(handle, 3, 9);
equal( target.width(), 103, "compare width"); equal( target.width(), 103, "compare width");
equal( target.height(), 100, "compare height"); equal( target.height(), 100, "compare height");
TestHelpers.resizable.drag(handle, 15, 11); resizableTestHelpers.drag(handle, 15, 11);
equal( target.width(), 118, "compare width"); equal( target.width(), 118, "compare width");
equal( target.height(), 120, "compare height"); equal( target.height(), 120, "compare height");
}); });
@ -252,11 +253,11 @@ test("grid (min/max dimensions)", function() {
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 }); var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 });
TestHelpers.resizable.drag(handle, 50, 50); resizableTestHelpers.drag(handle, 50, 50);
equal( target.width(), 120, "grid should respect maxWidth"); equal( target.width(), 120, "grid should respect maxWidth");
equal( target.height(), 120, "grid should respect maxHeight"); equal( target.height(), 120, "grid should respect maxHeight");
TestHelpers.resizable.drag(handle, -100, -100); resizableTestHelpers.drag(handle, -100, -100);
equal( target.width(), 80, "grid should respect minWidth"); equal( target.width(), 80, "grid should respect minWidth");
equal( target.height(), 80, "grid should respect minHeight"); equal( target.height(), 80, "grid should respect minHeight");
}); });
@ -266,11 +267,11 @@ test("grid (wrapped)", function() {
var handle = ".ui-resizable-se", target = $("#resizable2").resizable({ handles: "all", grid: [ 0, 20 ] }); var handle = ".ui-resizable-se", target = $("#resizable2").resizable({ handles: "all", grid: [ 0, 20 ] });
TestHelpers.resizable.drag(handle, 3, 9); resizableTestHelpers.drag(handle, 3, 9);
equal( target.width(), 103, "compare width"); equal( target.width(), 103, "compare width");
equal( target.height(), 100, "compare height"); equal( target.height(), 100, "compare height");
TestHelpers.resizable.drag(handle, 15, 11); resizableTestHelpers.drag(handle, 15, 11);
equal( target.width(), 118, "compare width"); equal( target.width(), 118, "compare width");
equal( target.height(), 120, "compare height"); equal( target.height(), 120, "compare height");
}); });
@ -285,13 +286,13 @@ test( "grid - Resizable: can be moved when grid option is set (#9611)", function
grid: 50 grid: 50
}); });
TestHelpers.resizable.drag( handle, 50, 50 ); resizableTestHelpers.drag( handle, 50, 50 );
equal( target.width(), 50, "compare width" ); equal( target.width(), 50, "compare width" );
equal( target.height(), 50, "compare height" ); equal( target.height(), 50, "compare height" );
oldPosition = target.position(); oldPosition = target.position();
TestHelpers.resizable.drag( handle, 50, 50 ); resizableTestHelpers.drag( handle, 50, 50 );
equal( target.width(), 50, "compare width" ); equal( target.width(), 50, "compare width" );
equal( target.height(), 50, "compare height" ); equal( target.height(), 50, "compare height" );
equal( target.position().top, oldPosition.top, "compare top" ); equal( target.position().top, oldPosition.top, "compare top" );
@ -313,7 +314,7 @@ test( "grid - maintains grid with padding and border when approaching no dimensi
grid: [ 50, 12 ] grid: [ 50, 12 ]
}); });
TestHelpers.resizable.drag( handle, 50, 50 ); resizableTestHelpers.drag( handle, 50, 50 );
equal( target.outerWidth(), 50, "compare width" ); equal( target.outerWidth(), 50, "compare width" );
equal( target.outerHeight(), 52, "compare height" ); equal( target.outerHeight(), 52, "compare height" );
}); });
@ -323,11 +324,11 @@ test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
TestHelpers.resizable.drag(handle, -50, -50); resizableTestHelpers.drag(handle, -50, -50);
equal( target.width(), 60, "compare minWidth" ); equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" ); equal( target.height(), 60, "compare minHeight" );
TestHelpers.resizable.drag(handle, 70, 70); resizableTestHelpers.drag(handle, 70, 70);
equal( target.width(), 100, "compare maxWidth" ); equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" ); equal( target.height(), 100, "compare maxHeight" );
}); });
@ -337,11 +338,11 @@ test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = ".ui-resizable-sw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
TestHelpers.resizable.drag(handle, 50, -50); resizableTestHelpers.drag(handle, 50, -50);
equal( target.width(), 60, "compare minWidth" ); equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" ); equal( target.height(), 60, "compare minHeight" );
TestHelpers.resizable.drag(handle, -70, 70); resizableTestHelpers.drag(handle, -70, 70);
equal( target.width(), 100, "compare maxWidth" ); equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" ); equal( target.height(), 100, "compare maxHeight" );
}); });
@ -351,11 +352,11 @@ test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = ".ui-resizable-ne", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
TestHelpers.resizable.drag(handle, -50, 50); resizableTestHelpers.drag(handle, -50, 50);
equal( target.width(), 60, "compare minWidth" ); equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" ); equal( target.height(), 60, "compare minHeight" );
TestHelpers.resizable.drag(handle, 70, -70); resizableTestHelpers.drag(handle, 70, -70);
equal( target.width(), 100, "compare maxWidth" ); equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" ); equal( target.height(), 100, "compare maxHeight" );
}); });
@ -365,11 +366,11 @@ test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 1
var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }); var handle = ".ui-resizable-nw", target = $("#resizable1").resizable({ handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
TestHelpers.resizable.drag(handle, 70, 70); resizableTestHelpers.drag(handle, 70, 70);
equal( target.width(), 60, "compare minWidth" ); equal( target.width(), 60, "compare minWidth" );
equal( target.height(), 60, "compare minHeight" ); equal( target.height(), 60, "compare minHeight" );
TestHelpers.resizable.drag(handle, -70, -70); resizableTestHelpers.drag(handle, -70, -70);
equal( target.width(), 100, "compare maxWidth" ); equal( target.width(), 100, "compare maxWidth" );
equal( target.height(), 100, "compare maxHeight" ); equal( target.height(), 100, "compare maxHeight" );
}); });
@ -381,10 +382,10 @@ test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }"
var handle = "#resizer1", var handle = "#resizer1",
target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" ) }, containment: "parent" }); target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" ) }, containment: "parent" });
TestHelpers.resizable.drag( handle, 0, 70 ); resizableTestHelpers.drag( handle, 0, 70 );
equal( target.height(), 170, "compare height" ); equal( target.height(), 170, "compare height" );
TestHelpers.resizable.drag( handle, 0, -70 ); resizableTestHelpers.drag( handle, 0, -70 );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
}); });
@ -395,10 +396,10 @@ test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent'
var handle = "#resizer1", var handle = "#resizer1",
target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" }); target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" });
TestHelpers.resizable.drag( handle, 0, 70 ); resizableTestHelpers.drag( handle, 0, 70 );
equal( target.height(), 170, "compare height" ); equal( target.height(), 170, "compare height" );
TestHelpers.resizable.drag( handle, 0, -70 ); resizableTestHelpers.drag( handle, 0, -70 );
equal( target.height(), 100, "compare height" ); equal( target.height(), 100, "compare height" );
}); });
@ -425,7 +426,7 @@ test( "alsoResize + containment", function() {
containment: "#container" containment: "#container"
}); });
TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 ); resizableTestHelpers.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "resizable constrained width at containment edge" ); equal( element.width(), 300, "resizable constrained width at containment edge" );
equal( element.height(), 200, "resizable constrained height at containment edge" ); equal( element.height(), 200, "resizable constrained height at containment edge" );
equal( other.width(), 250, "alsoResize constrained width at containment edge" ); equal( other.width(), 250, "alsoResize constrained width at containment edge" );
@ -453,7 +454,7 @@ test( "alsoResize + multiple selection", function() {
containment: "#container" containment: "#container"
}); });
TestHelpers.resizable.drag( ".ui-resizable-se", 400, 400 ); resizableTestHelpers.drag( ".ui-resizable-se", 400, 400 );
equal( element.width(), 300, "resizable constrained width at containment edge" ); equal( element.width(), 300, "resizable constrained width at containment edge" );
equal( element.height(), 200, "resizable constrained height at containment edge" ); equal( element.height(), 200, "resizable constrained height at containment edge" );
equal( other1.width(), 250, "alsoResize o1 constrained width at containment edge" ); equal( other1.width(), 250, "alsoResize o1 constrained width at containment edge" );
@ -462,4 +463,4 @@ test( "alsoResize + multiple selection", function() {
equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" ); equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" );
}); });
})(jQuery); } );

View File

@ -1,4 +1,6 @@
TestHelpers.resizable = { define( function() {
return {
drag: function( el, dx, dy ) { drag: function( el, dx, dy ) {
// this mouseover is to work around a limitation in resizable // this mouseover is to work around a limitation in resizable
// TODO: fix resizable so handle doesn't require mouseover in order to be used // TODO: fix resizable so handle doesn't require mouseover in order to be used
@ -9,3 +11,5 @@ TestHelpers.resizable = {
}); });
} }
}; };
} );