Skip to content
Permalink
Browse files

Resizable: Convert tests to new infrastructure

Ref #10119
Ref gh-1528
  • Loading branch information...
scottgonzalez committed Apr 6, 2015
1 parent df3e8c4 commit 4e7407cd699bcb02cfdd6e28d463831e782233e7
@@ -4,33 +4,8 @@
<meta charset="utf-8">
<title>jQuery UI Resizable Test Suite</title>

<script src="../../jquery.js"></script>
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
<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>

<script src="../../lib/css.js" data-modules="core resizable"></script>
<script src="../../lib/bootstrap.js" data-widget="resizable"></script>
<style>
#container {
width: 300px;
@@ -1,4 +1,9 @@
TestHelpers.commonWidgetTests( "resizable", {
define( [
"lib/common",
"ui/resizable"
], function( common ) {

common.testWidget( "resizable", {
defaults: {
alsoResize: false,
animate: false,
@@ -31,3 +36,5 @@ TestHelpers.commonWidgetTests( "resizable", {
stop: null
}
});

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

(function($) {
define( [
"jquery",
"./resizable_test_helpers",
"ui/resizable"
], function( $, resizableTestHelpers ) {

module("resizable: core");

@@ -30,10 +30,10 @@ test("n", function() {

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" );

TestHelpers.resizable.drag(handle, 0, 50);
resizableTestHelpers.drag(handle, 0, 50);
equal( target.height(), 100, "compare height" );

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" });

TestHelpers.resizable.drag(handle, 0, 50);
resizableTestHelpers.drag(handle, 0, 50);
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[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" });

TestHelpers.resizable.drag(handle, 50);
resizableTestHelpers.drag(handle, 50);
equal( target.width(), 150, "compare width");

TestHelpers.resizable.drag(handle, -50);
resizableTestHelpers.drag(handle, -50);
equal( target.width(), 100, "compare width" );

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" });

TestHelpers.resizable.drag(handle, -50);
resizableTestHelpers.drag(handle, -50);
equal( target.width(), 150, "compare width" );

TestHelpers.resizable.drag(handle, 50);
resizableTestHelpers.drag(handle, 50);
equal( target.width(), 100, "compare width" );

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" });

TestHelpers.resizable.drag(handle, -50, -50);
resizableTestHelpers.drag(handle, -50, -50);
equal( target.width(), 50, "compare width" );
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.height(), 100, "compare height" );

@@ -108,11 +108,11 @@ test("se", function() {

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.height(), 150, "compare height" );

TestHelpers.resizable.drag(handle, -50, -50);
resizableTestHelpers.drag(handle, -50, -50);
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );

@@ -125,11 +125,11 @@ test("sw", function() {

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.height(), 50, "compare height" );

TestHelpers.resizable.drag(handle, 50, 50);
resizableTestHelpers.drag(handle, 50, 50);
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );

@@ -141,11 +141,11 @@ test("nw", function() {

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.height(), 150, "compare height" );

TestHelpers.resizable.drag(handle, 50, 50);
resizableTestHelpers.drag(handle, 50, 50);
equal( target.width(), 100, "compare width" );
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" });

TestHelpers.resizable.drag(handle, -50);
resizableTestHelpers.drag(handle, -50);
equal( target.width(), 150, "compare width" );

TestHelpers.resizable.drag(handle, 50);
resizableTestHelpers.drag(handle, 50);
equal( target.width(), 100, "compare width" );
});

@@ -186,7 +186,7 @@ test("resizable accounts for scroll position correctly (#3815)", function() {
left = el.css("left");
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" );
equal( el.css("left"), left, "css('left') 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 ]
});

TestHelpers.resizable.drag( handle, 1, 1 );
resizableTestHelpers.drag( handle, 1, 1 );
equal( target.width(), 100, "compare width" );
equal( target.height(), 100, "compare height" );
});
@@ -227,18 +227,18 @@ test( "nested resizable", function() {
innerHandle = $( "#inner > .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" );
TestHelpers.resizable.drag( innerHandle, -10 );
resizableTestHelpers.drag( innerHandle, -10 );
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" );
TestHelpers.resizable.drag( outerHandle, -10 );
resizableTestHelpers.drag( outerHandle, -10 );
equal( outer.width(), 50, "compare width of outer element" );

inner.remove();
outer.remove();
});

})(jQuery);
} );
@@ -1,7 +1,8 @@
/*
* resizable_events.js
*/
(function($) {
define( [
"jquery",
"./resizable_test_helpers",
"ui/resizable"
], function( $, resizableTestHelpers ) {

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");

@@ -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" );

@@ -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" );

@@ -112,10 +113,10 @@ test( "resize (containment)", function() {
});

// 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
TestHelpers.resizable.drag( handle, -200, -200 );
resizableTestHelpers.drag( handle, -200, -200 );

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");

@@ -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.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");

@@ -230,12 +231,12 @@ test( "resize (containment) works with parent with negative offset", function()

widthBefore = target.width();

TestHelpers.resizable.drag( handle, increaseWidthBy, 0 );
resizableTestHelpers.drag( handle, increaseWidthBy, 0 );

widthAfter = target.width();

equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" );

});

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

module( "resizable: methods" );

@@ -18,4 +18,4 @@ test( "disable", function( assert ) {
equal( chainable, element, "disable is chainable" );
});

})(jQuery);
} );
Oops, something went wrong.

0 comments on commit 4e7407c

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