From 611e3648b5b2fa10a7004d27a45935a929341326 Mon Sep 17 00:00:00 2001 From: Amanpreet Singh Date: Wed, 6 Apr 2016 18:41:09 +0530 Subject: [PATCH] Resizeable: Shift to use no globals --- tests/unit/resizable/core.js | 155 ++++++++-------- tests/unit/resizable/events.js | 115 ++++++------ tests/unit/resizable/helper.js | 5 +- tests/unit/resizable/methods.js | 15 +- tests/unit/resizable/options.js | 317 ++++++++++++++++---------------- 5 files changed, 306 insertions(+), 301 deletions(-) diff --git a/tests/unit/resizable/core.js b/tests/unit/resizable/core.js index 8c942e62f..8c58405e3 100644 --- a/tests/unit/resizable/core.js +++ b/tests/unit/resizable/core.js @@ -1,13 +1,14 @@ define( [ + "qunit", "jquery", "./helper", "ui/widgets/resizable" -], function( $, testHelper ) { +], function( QUnit, $, testHelper ) { -module( "resizable: core" ); +QUnit.module( "resizable: core" ); /* -test("element types", function() { +Test("element types", function() { var typeNames = ("p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form" + ",table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr" + ",acronym,code,samp,kbd,var,img,object,hr" @@ -25,133 +26,133 @@ test("element types", function() { }); */ -test( "n", function() { - expect( 4 ); +QUnit.test( "n", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { handles: "all" } ); testHelper.drag( handle, 0, -50 ); - equal( target.height(), 150, "compare height" ); + assert.equal( target.height(), 150, "compare height" ); testHelper.drag( handle, 0, 50 ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.height(), 100, "compare height" ); - equal( target[ 0 ].style.left, "", "left should not be modified" ); - equal( target[ 0 ].style.width, "", "width should not be modified" ); + assert.equal( target[ 0 ].style.left, "", "left should not be modified" ); + assert.equal( target[ 0 ].style.width, "", "width should not be modified" ); } ); -test( "s", function() { - expect( 5 ); +QUnit.test( "s", function( assert ) { + assert.expect( 5 ); var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { handles: "all" } ); testHelper.drag( handle, 0, 50 ); - equal( target.height(), 150, "compare height" ); + assert.equal( target.height(), 150, "compare height" ); testHelper.drag( handle, 0, -50 ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.height(), 100, "compare height" ); - equal( target[ 0 ].style.top, "", "top should not be modified" ); - equal( target[ 0 ].style.left, "", "left should not be modified" ); - equal( target[ 0 ].style.width, "", "width should not be modified" ); + assert.equal( target[ 0 ].style.top, "", "top should not be modified" ); + assert.equal( target[ 0 ].style.left, "", "left should not be modified" ); + assert.equal( target[ 0 ].style.width, "", "width should not be modified" ); } ); -test( "e", function() { - expect( 5 ); +QUnit.test( "e", function( assert ) { + assert.expect( 5 ); var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { handles: "all" } ); testHelper.drag( handle, 50 ); - equal( target.width(), 150, "compare width" ); + assert.equal( target.width(), 150, "compare width" ); testHelper.drag( handle, -50 ); - equal( target.width(), 100, "compare width" ); + assert.equal( target.width(), 100, "compare width" ); - equal( target[ 0 ].style.height, "", "height should not be modified" ); - equal( target[ 0 ].style.top, "", "top should not be modified" ); - equal( target[ 0 ].style.left, "", "left should not be modified" ); + assert.equal( target[ 0 ].style.height, "", "height should not be modified" ); + assert.equal( target[ 0 ].style.top, "", "top should not be modified" ); + assert.equal( target[ 0 ].style.left, "", "left should not be modified" ); } ); -test( "w", function() { - expect( 4 ); +QUnit.test( "w", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { handles: "all" } ); testHelper.drag( handle, -50 ); - equal( target.width(), 150, "compare width" ); + assert.equal( target.width(), 150, "compare width" ); testHelper.drag( handle, 50 ); - equal( target.width(), 100, "compare width" ); + assert.equal( target.width(), 100, "compare width" ); - equal( target[ 0 ].style.height, "", "height should not be modified" ); - equal( target[ 0 ].style.top, "", "top should not be modified" ); + assert.equal( target[ 0 ].style.height, "", "height should not be modified" ); + assert.equal( target[ 0 ].style.top, "", "top should not be modified" ); } ); -test( "ne", function() { - expect( 5 ); +QUnit.test( "ne", function( assert ) { + assert.expect( 5 ); var handle = ".ui-resizable-ne", target = $( "#resizable1" ).css( { overflow: "hidden" } ).resizable( { handles: "all" } ); testHelper.drag( handle, -50, -50 ); - equal( target.width(), 50, "compare width" ); - equal( target.height(), 150, "compare height" ); + assert.equal( target.width(), 50, "compare width" ); + assert.equal( target.height(), 150, "compare height" ); testHelper.drag( handle, 50, 50 ); - equal( target.width(), 100, "compare width" ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.width(), 100, "compare width" ); + assert.equal( target.height(), 100, "compare height" ); - equal( target[ 0 ].style.left, "", "left should not be modified" ); + assert.equal( target[ 0 ].style.left, "", "left should not be modified" ); } ); -test( "se", function() { - expect( 6 ); +QUnit.test( "se", function( assert ) { + assert.expect( 6 ); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all" } ); testHelper.drag( handle, 50, 50 ); - equal( target.width(), 150, "compare width" ); - equal( target.height(), 150, "compare height" ); + assert.equal( target.width(), 150, "compare width" ); + assert.equal( target.height(), 150, "compare height" ); testHelper.drag( handle, -50, -50 ); - equal( target.width(), 100, "compare width" ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.width(), 100, "compare width" ); + assert.equal( target.height(), 100, "compare height" ); - equal( target[ 0 ].style.top, "", "top should not be modified" ); - equal( target[ 0 ].style.left, "", "left should not be modified" ); + assert.equal( target[ 0 ].style.top, "", "top should not be modified" ); + assert.equal( target[ 0 ].style.left, "", "left should not be modified" ); } ); -test( "sw", function() { - expect( 5 ); +QUnit.test( "sw", function( assert ) { + assert.expect( 5 ); var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all" } ); testHelper.drag( handle, -50, -50 ); - equal( target.width(), 150, "compare width" ); - equal( target.height(), 50, "compare height" ); + assert.equal( target.width(), 150, "compare width" ); + assert.equal( target.height(), 50, "compare height" ); testHelper.drag( handle, 50, 50 ); - equal( target.width(), 100, "compare width" ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.width(), 100, "compare width" ); + assert.equal( target.height(), 100, "compare height" ); - equal( target[ 0 ].style.top, "", "top should not be modified" ); + assert.equal( target[ 0 ].style.top, "", "top should not be modified" ); } ); -test( "nw", function() { - expect( 4 ); +QUnit.test( "nw", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all" } ); testHelper.drag( handle, -50, -50 ); - equal( target.width(), 150, "compare width" ); - equal( target.height(), 150, "compare height" ); + assert.equal( target.width(), 150, "compare width" ); + assert.equal( target.height(), 150, "compare height" ); testHelper.drag( handle, 50, 50 ); - equal( target.width(), 100, "compare width" ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.width(), 100, "compare width" ); + assert.equal( target.height(), 100, "compare height" ); } ); -test( "handle with complex markup (#8756)", function() { - expect( 2 ); +QUnit.test( "handle with complex markup (#8756)", function( assert ) { + assert.expect( 2 ); $( "#resizable1" ) .append( @@ -164,14 +165,14 @@ test( "handle with complex markup (#8756)", function() { var handle = ".ui-resizable-w div", target = $( "#resizable1" ).resizable( { handles: "all" } ); testHelper.drag( handle, -50 ); - equal( target.width(), 150, "compare width" ); + assert.equal( target.width(), 150, "compare width" ); testHelper.drag( handle, 50 ); - equal( target.width(), 100, "compare width" ); + assert.equal( target.width(), 100, "compare width" ); } ); -test( "resizable accounts for scroll position correctly (#3815)", function() { - expect( 4 ); +QUnit.test( "resizable accounts for scroll position correctly (#3815)", function( assert ) { + assert.expect( 4 ); var position, top, left, container = $( "
" ).appendTo( "#qunit-fixture" ), @@ -187,14 +188,14 @@ test( "resizable accounts for scroll position correctly (#3815)", function() { top = el.css( "top" ); testHelper.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" ); - equal( $( handle ).position().left, handlePosition + 50, "handle also moved" ); + assert.deepEqual( el.position(), position, "position stays the same when resized" ); + assert.equal( el.css( "left" ), left, "css('left') stays the same when resized" ); + assert.equal( el.css( "top" ), top, "css('top') stays the same when resized" ); + assert.equal( $( handle ).position().left, handlePosition + 50, "handle also moved" ); } ); -test( "resizable stores correct size when using helper and grid (#9547)", function() { - expect( 2 ); +QUnit.test( "resizable stores correct size when using helper and grid (#9547)", function( assert ) { + assert.expect( 2 ); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { @@ -204,12 +205,12 @@ test( "resizable stores correct size when using helper and grid (#9547)", functi } ); testHelper.drag( handle, 1, 1 ); - equal( target.width(), 100, "compare width" ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.width(), 100, "compare width" ); + assert.equal( target.height(), 100, "compare height" ); } ); -test( "nested resizable", function() { - expect( 4 ); +QUnit.test( "nested resizable", function( assert ) { + assert.expect( 4 ); var outer = $( "
" ), inner = $( "
" ), @@ -228,14 +229,14 @@ test( "nested resizable", function() { outerHandle = $( "#outer > .ui-resizable-e" ); testHelper.drag( innerHandle, 10 ); - equal( inner.width(), 40, "compare width of inner element" ); + assert.equal( inner.width(), 40, "compare width of inner element" ); testHelper.drag( innerHandle, -10 ); - equal( inner.width(), 30, "compare width of inner element" ); + assert.equal( inner.width(), 30, "compare width of inner element" ); testHelper.drag( outerHandle, 10 ); - equal( outer.width(), 60, "compare width of outer element" ); + assert.equal( outer.width(), 60, "compare width of outer element" ); testHelper.drag( outerHandle, -10 ); - equal( outer.width(), 50, "compare width of outer element" ); + assert.equal( outer.width(), 50, "compare width of outer element" ); inner.remove(); outer.remove(); diff --git a/tests/unit/resizable/events.js b/tests/unit/resizable/events.js index b12cfa8d5..4e3968726 100644 --- a/tests/unit/resizable/events.js +++ b/tests/unit/resizable/events.js @@ -1,14 +1,15 @@ define( [ + "qunit", "jquery", "./helper", "ui/widgets/resizable" -], function( $, testHelper ) { +], function( QUnit, $, testHelper ) { -module( "resizable: events" ); +QUnit.module( "resizable: events" ); -test( "start", function() { +QUnit.test( "start", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var count = 0, handle = ".ui-resizable-se"; @@ -16,23 +17,23 @@ test( "start", function() { $( "#resizable1" ).resizable( { handles: "all", start: function( event, ui ) { - equal( ui.size.width, 100, "compare width" ); - equal( ui.size.height, 100, "compare height" ); - equal( ui.originalSize.width, 100, "compare original width" ); - equal( ui.originalSize.height, 100, "compare original height" ); + assert.equal( ui.size.width, 100, "compare width" ); + assert.equal( ui.size.height, 100, "compare height" ); + assert.equal( ui.originalSize.width, 100, "compare original width" ); + assert.equal( ui.originalSize.height, 100, "compare original height" ); count++; } } ); testHelper.drag( handle, 50, 50 ); - equal( count, 1, "start callback should happen exactly once" ); + assert.equal( count, 1, "start callback should happen exactly once" ); } ); -test( "resize", function() { +QUnit.test( "resize", function( assert ) { - expect( 9 ); + assert.expect( 9 ); var count = 0, handle = ".ui-resizable-se"; @@ -41,15 +42,15 @@ test( "resize", function() { handles: "all", resize: function( event, ui ) { if ( count === 0 ) { - equal( ui.size.width, 125, "compare width" ); - equal( ui.size.height, 125, "compare height" ); - equal( ui.originalSize.width, 100, "compare original width" ); - equal( ui.originalSize.height, 100, "compare original height" ); + assert.equal( ui.size.width, 125, "compare width" ); + assert.equal( ui.size.height, 125, "compare height" ); + assert.equal( ui.originalSize.width, 100, "compare original width" ); + assert.equal( ui.originalSize.height, 100, "compare original height" ); } else { - equal( ui.size.width, 150, "compare width" ); - equal( ui.size.height, 150, "compare height" ); - equal( ui.originalSize.width, 100, "compare original width" ); - equal( ui.originalSize.height, 100, "compare original height" ); + assert.equal( ui.size.width, 150, "compare width" ); + assert.equal( ui.size.height, 150, "compare height" ); + assert.equal( ui.originalSize.width, 100, "compare original width" ); + assert.equal( ui.originalSize.height, 100, "compare original height" ); } count++; } @@ -57,13 +58,13 @@ test( "resize", function() { testHelper.drag( handle, 50, 50 ); - equal( count, 2, "resize callback should happen exactly once per size adjustment" ); + assert.equal( count, 2, "resize callback should happen exactly once per size adjustment" ); } ); -test( "resize (min/max dimensions)", function() { +QUnit.test( "resize (min/max dimensions)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var count = 0, handle = ".ui-resizable-se"; @@ -75,23 +76,23 @@ test( "resize (min/max dimensions)", function() { maxWidth: 100, maxHeight: 100, resize: function( event, ui ) { - equal( ui.size.width, 60, "compare width" ); - equal( ui.size.height, 60, "compare height" ); - equal( ui.originalSize.width, 100, "compare original width" ); - equal( ui.originalSize.height, 100, "compare original height" ); + assert.equal( ui.size.width, 60, "compare width" ); + assert.equal( ui.size.height, 60, "compare height" ); + assert.equal( ui.originalSize.width, 100, "compare original width" ); + assert.equal( ui.originalSize.height, 100, "compare original height" ); count++; } } ); testHelper.drag( handle, -200, -200 ); - equal( count, 1, "resize callback should happen exactly once per size adjustment" ); + assert.equal( count, 1, "resize callback should happen exactly once per size adjustment" ); } ); -test( "resize (containment)", function() { +QUnit.test( "resize (containment)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var count = 0, handle = ".ui-resizable-se", @@ -104,10 +105,10 @@ test( "resize (containment)", function() { handles: "all", containment: container, resize: function( event, ui ) { - equal( ui.size.width, 10, "compare width" ); - equal( ui.size.height, 10, "compare height" ); - equal( ui.originalSize.width, 100, "compare original width" ); - equal( ui.originalSize.height, 100, "compare original height" ); + assert.equal( ui.size.width, 10, "compare width" ); + assert.equal( ui.size.height, 10, "compare height" ); + assert.equal( ui.originalSize.width, 100, "compare original width" ); + assert.equal( ui.originalSize.height, 100, "compare original height" ); count++; } } ); @@ -118,13 +119,13 @@ test( "resize (containment)", function() { // Prove you can't resize outside containment by dragging southeast corner northwest testHelper.drag( handle, -200, -200 ); - equal( count, 1, "resize callback should happen exactly once per size adjustment" ); + assert.equal( count, 1, "resize callback should happen exactly once per size adjustment" ); } ); -test( "resize (grid)", function() { +QUnit.test( "resize (grid)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var count = 0, handle = ".ui-resizable-se"; @@ -133,22 +134,22 @@ test( "resize (grid)", function() { handles: "all", grid: 50, resize: function( event, ui ) { - equal( ui.size.width, 150, "compare width" ); - equal( ui.size.height, 150, "compare height" ); - equal( ui.originalSize.width, 100, "compare original width" ); - equal( ui.originalSize.height, 100, "compare original height" ); + assert.equal( ui.size.width, 150, "compare width" ); + assert.equal( ui.size.height, 150, "compare height" ); + assert.equal( ui.originalSize.width, 100, "compare original width" ); + assert.equal( ui.originalSize.height, 100, "compare original height" ); count++; } } ); testHelper.drag( handle, 50, 50 ); - equal( count, 1, "resize callback should happen exactly once per grid-unit size adjustment" ); + assert.equal( count, 1, "resize callback should happen exactly once per grid-unit size adjustment" ); } ); -test( "resize, custom adjustment", function() { - expect( 4 ); +QUnit.test( "resize, custom adjustment", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-se", element = $( "#resizable1" ).resizable( { @@ -162,15 +163,15 @@ test( "resize, custom adjustment", function() { testHelper.drag( handle, 50, 50 ); - equal( element.width(), 100, "resize event can control width" ); - equal( element.height(), 200, "resize event can control height" ); - equal( element.position().left, 300, "resize event can control left" ); - equal( element.position().top, 400, "resize event can control top" ); + assert.equal( element.width(), 100, "resize event can control width" ); + assert.equal( element.height(), 200, "resize event can control height" ); + assert.equal( element.position().left, 300, "resize event can control left" ); + assert.equal( element.position().top, 400, "resize event can control top" ); } ); -test( "stop", function() { +QUnit.test( "stop", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var count = 0, handle = ".ui-resizable-se"; @@ -178,23 +179,23 @@ test( "stop", function() { $( "#resizable1" ).resizable( { handles: "all", stop: function( event, ui ) { - equal( ui.size.width, 150, "compare width" ); - equal( ui.size.height, 150, "compare height" ); - equal( ui.originalSize.width, 100, "compare original width" ); - equal( ui.originalSize.height, 100, "compare original height" ); + assert.equal( ui.size.width, 150, "compare width" ); + assert.equal( ui.size.height, 150, "compare height" ); + assert.equal( ui.originalSize.width, 100, "compare original width" ); + assert.equal( ui.originalSize.height, 100, "compare original height" ); count++; } } ); testHelper.drag( handle, 50, 50 ); - equal( count, 1, "stop callback should happen exactly once" ); + assert.equal( count, 1, "stop callback should happen exactly once" ); } ); -test( "resize (containment) works with parent with negative offset", function() { +QUnit.test( "resize (containment) works with parent with negative offset", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var widthBefore, widthAfter, handle = ".ui-resizable-e", @@ -235,7 +236,7 @@ test( "resize (containment) works with parent with negative offset", function() widthAfter = target.width(); - equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" ); + assert.equal( widthAfter, ( widthBefore + increaseWidthBy ), "resizable width should be increased by the value dragged" ); } ); diff --git a/tests/unit/resizable/helper.js b/tests/unit/resizable/helper.js index f541d69c7..2b8c2b46d 100644 --- a/tests/unit/resizable/helper.js +++ b/tests/unit/resizable/helper.js @@ -1,12 +1,13 @@ define( [ + "qunit", "jquery", "lib/helper" -], function( $, helper ) { +], function( QUnit, $, helper ) { return $.extend( helper, { 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 $( el ).simulate( "mouseover" ).simulate( "drag", { moves: 2, diff --git a/tests/unit/resizable/methods.js b/tests/unit/resizable/methods.js index eea42a682..7ee49eee6 100644 --- a/tests/unit/resizable/methods.js +++ b/tests/unit/resizable/methods.js @@ -1,21 +1,22 @@ define( [ + "qunit", "jquery", "ui/widgets/resizable" -], function( $ ) { +], function( QUnit, $ ) { -module( "resizable: methods" ); +QUnit.module( "resizable: methods" ); -test( "disable", function( assert ) { - expect( 5 ); +QUnit.test( "disable", function( assert ) { + assert.expect( 5 ); var element = $( "#resizable1" ).resizable( { disabled: false } ), chainable = element.resizable( "disable" ); assert.lacksClasses( element.resizable( "widget" ), "ui-state-disabled" ); - ok( !element.resizable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); + assert.ok( !element.resizable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); assert.hasClasses( element.resizable( "widget" ), "ui-resizable-disabled" ); - equal( element.resizable( "option", "disabled" ), true, "disabled option setter" ); - equal( chainable, element, "disable is chainable" ); + assert.equal( element.resizable( "option", "disabled" ), true, "disabled option setter" ); + assert.equal( chainable, element, "disable is chainable" ); } ); } ); diff --git a/tests/unit/resizable/options.js b/tests/unit/resizable/options.js index ae390ad93..6eeba98dd 100644 --- a/tests/unit/resizable/options.js +++ b/tests/unit/resizable/options.js @@ -1,13 +1,14 @@ define( [ + "qunit", "jquery", "./helper", "ui/widgets/resizable" -], function( $, testHelper ) { +], function( QUnit, $, testHelper ) { -module( "resizable: options" ); +QUnit.module( "resizable: options" ); -test( "alsoResize", function() { - expect( 2 ); +QUnit.test( "alsoResize", function( assert ) { + assert.expect( 2 ); var other = $( "
" ) .css( { @@ -21,110 +22,110 @@ test( "alsoResize", function() { handle = ".ui-resizable-e"; testHelper.drag( handle, 80 ); - equal( element.width(), 180, "resizable width" ); - equal( other.width(), 130, "alsoResize width" ); + assert.equal( element.width(), 180, "resizable width" ); + assert.equal( other.width(), 130, "alsoResize width" ); } ); -test( "aspectRatio: 'preserve' (e)", function() { - expect( 4 ); +QUnit.test( "aspectRatio: 'preserve' (e)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-e", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } ); testHelper.drag( handle, 80 ); - equal( target.width(), 130, "compare maxWidth" ); - equal( target.height(), 130, "compare maxHeight" ); + assert.equal( target.width(), 130, "compare maxWidth" ); + assert.equal( target.height(), 130, "compare maxHeight" ); testHelper.drag( handle, -130 ); - equal( target.width(), 70, "compare minWidth" ); - equal( target.height(), 70, "compare minHeight" ); + assert.equal( target.width(), 70, "compare minWidth" ); + assert.equal( target.height(), 70, "compare minHeight" ); } ); -test( "aspectRatio: 'preserve' (w)", function() { - expect( 4 ); +QUnit.test( "aspectRatio: 'preserve' (w)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-w", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } ); testHelper.drag( handle, -80 ); - equal( target.width(), 130, "compare maxWidth" ); - equal( target.height(), 130, "compare maxHeight" ); + assert.equal( target.width(), 130, "compare maxWidth" ); + assert.equal( target.height(), 130, "compare maxHeight" ); testHelper.drag( handle, 130 ); - equal( target.width(), 70, "compare minWidth" ); - equal( target.height(), 70, "compare minHeight" ); + assert.equal( target.width(), 70, "compare minWidth" ); + assert.equal( target.height(), 70, "compare minHeight" ); } ); -test( "aspectRatio: 'preserve' (n)", function() { - expect( 4 ); +QUnit.test( "aspectRatio: 'preserve' (n)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-n", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } ); testHelper.drag( handle, 0, -80 ); - equal( target.width(), 130, "compare maxWidth" ); - equal( target.height(), 130, "compare maxHeight" ); + assert.equal( target.width(), 130, "compare maxWidth" ); + assert.equal( target.height(), 130, "compare maxHeight" ); testHelper.drag( handle, 0, 80 ); - equal( target.width(), 70, "compare minWidth" ); - equal( target.height(), 70, "compare minHeight" ); + assert.equal( target.width(), 70, "compare minWidth" ); + assert.equal( target.height(), 70, "compare minHeight" ); } ); -test( "aspectRatio: 'preserve' (s)", function() { - expect( 4 ); +QUnit.test( "aspectRatio: 'preserve' (s)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-s", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } ); testHelper.drag( handle, 0, 80 ); - equal( target.width(), 130, "compare maxWidth" ); - equal( target.height(), 130, "compare maxHeight" ); + assert.equal( target.width(), 130, "compare maxWidth" ); + assert.equal( target.height(), 130, "compare maxHeight" ); testHelper.drag( handle, 0, -80 ); - equal( target.width(), 70, "compare minWidth" ); - equal( target.height(), 70, "compare minHeight" ); + assert.equal( target.width(), 70, "compare minWidth" ); + assert.equal( target.height(), 70, "compare minHeight" ); } ); -test( "aspectRatio: 'preserve' (se)", function() { - expect( 4 ); +QUnit.test( "aspectRatio: 'preserve' (se)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } ); testHelper.drag( handle, 80, 80 ); - equal( target.width(), 130, "compare maxWidth" ); - equal( target.height(), 130, "compare maxHeight" ); + assert.equal( target.width(), 130, "compare maxWidth" ); + assert.equal( target.height(), 130, "compare maxHeight" ); testHelper.drag( handle, -80, -80 ); - equal( target.width(), 70, "compare minWidth" ); - equal( target.height(), 70, "compare minHeight" ); + assert.equal( target.width(), 70, "compare minWidth" ); + assert.equal( target.height(), 70, "compare minHeight" ); } ); -test( "aspectRatio: 'preserve' (sw)", function() { - expect( 4 ); +QUnit.test( "aspectRatio: 'preserve' (sw)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } ); testHelper.drag( handle, -80, 80 ); - equal( target.width(), 130, "compare maxWidth" ); - equal( target.height(), 130, "compare maxHeight" ); + assert.equal( target.width(), 130, "compare maxWidth" ); + assert.equal( target.height(), 130, "compare maxHeight" ); testHelper.drag( handle, 80, -80 ); - equal( target.width(), 70, "compare minWidth" ); - equal( target.height(), 70, "compare minHeight" ); + assert.equal( target.width(), 70, "compare minWidth" ); + assert.equal( target.height(), 70, "compare minHeight" ); } ); -test( "aspectRatio: 'preserve' (ne)", function() { - expect( 4 ); +QUnit.test( "aspectRatio: 'preserve' (ne)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { aspectRatio: "preserve", handles: "all", minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 } ); testHelper.drag( handle, 80, -80 ); - equal( target.width(), 130, "compare maxWidth" ); - equal( target.height(), 130, "compare maxHeight" ); + assert.equal( target.width(), 130, "compare maxWidth" ); + assert.equal( target.height(), 130, "compare maxHeight" ); testHelper.drag( handle, -80, 80 ); - equal( target.width(), 70, "compare minWidth" ); - equal( target.height(), 70, "compare minHeight" ); + assert.equal( target.width(), 70, "compare minWidth" ); + assert.equal( target.height(), 70, "compare minHeight" ); } ); -test( "aspectRatio: Resizing can move objects", function() { - expect( 7 ); +QUnit.test( "aspectRatio: Resizing can move objects", function( assert ) { + assert.expect( 7 ); // Http://bugs.jqueryui.com/ticket/7018 - Resizing can move objects var handleW = ".ui-resizable-w", @@ -139,39 +140,39 @@ test( "aspectRatio: Resizing can move objects", function() { $( "#resizable1" ).css( { width: 100, height: 100, left: 75, top: 200 } ); testHelper.drag( handleW, -20 ); - equal( target.width(), 100, "compare width - no size change" ); - equal( target.height(), 100, "compare height - no size change" ); - equal( target.position().left, 75, "compare left - no movement" ); + assert.equal( target.width(), 100, "compare width - no size change" ); + assert.equal( target.height(), 100, "compare height - no size change" ); + assert.equal( target.position().left, 75, "compare left - no movement" ); // Http://bugs.jqueryui.com/ticket/9107 - aspectRatio and containment not handled correctly $( "#container" ).css( { width: 200, height: 300, position: "absolute", left: 100, top: 100 } ); $( "#resizable1" ).css( { width: 100, height: 100, left: 0, top: 0 } ); testHelper.drag( handleNW, -20, -20 ); - equal( target.width(), 100, "compare width - no size change" ); - equal( target.height(), 100, "compare height - no size change" ); - equal( target.position().left, 0, "compare left - no movement" ); - equal( target.position().top, 0, "compare top - no movement" ); + assert.equal( target.width(), 100, "compare width - no size change" ); + assert.equal( target.height(), 100, "compare height - no size change" ); + assert.equal( target.position().left, 0, "compare left - no movement" ); + assert.equal( target.position().top, 0, "compare top - no movement" ); } ); -test( "containment", function() { - expect( 4 ); +QUnit.test( "containment", function( assert ) { + assert.expect( 4 ); var element = $( "#resizable1" ).resizable( { containment: "#container" } ); testHelper.drag( ".ui-resizable-se", 20, 30 ); - equal( element.width(), 120, "unconstrained width within container" ); - equal( element.height(), 130, "unconstrained height within container" ); + assert.equal( element.width(), 120, "unconstrained width within container" ); + assert.equal( element.height(), 130, "unconstrained height within container" ); testHelper.drag( ".ui-resizable-se", 400, 400 ); - equal( element.width(), 300, "constrained width at containment edge" ); - equal( element.height(), 200, "constrained height at containment edge" ); + assert.equal( element.width(), 300, "constrained width at containment edge" ); + assert.equal( element.height(), 200, "constrained height at containment edge" ); } ); -test( "containment - not immediate parent", function() { - expect( 4 ); +QUnit.test( "containment - not immediate parent", function( assert ) { + assert.expect( 4 ); // Http://bugs.jqueryui.com/ticket/7485 - Resizable: Containment calculation is wrong // when containment element is not the immediate parent @@ -181,10 +182,10 @@ test( "containment - not immediate parent", function() { } ); testHelper.drag( ".ui-resizable-e", 300, 0 ); - equal( element.width(), 400, "Relative, contained within container width" ); + assert.equal( element.width(), 400, "Relative, contained within container width" ); testHelper.drag( ".ui-resizable-s", 0, 300 ); - equal( element.height(), 400, "Relative, contained within container height" ); + assert.equal( element.height(), 400, "Relative, contained within container height" ); $( "#child" ).css( { left: 50, top: 50 } ); $( "#parent" ).css( { left: 50, top: 50 } ); @@ -196,14 +197,14 @@ test( "containment - not immediate parent", function() { } ); testHelper.drag( ".ui-resizable-e", 400, 0 ); - equal( element.width(), 300, "Relative with Left, contained within container width" ); + assert.equal( element.width(), 300, "Relative with Left, contained within container width" ); testHelper.drag( ".ui-resizable-s", 0, 400 ); - equal( element.height(), 300, "Relative with Top, contained within container height" ); + assert.equal( element.height(), 300, "Relative with Top, contained within container height" ); } ); -test( "containment - immediate parent", function() { - expect( 4 ); +QUnit.test( "containment - immediate parent", function( assert ) { + assert.expect( 4 ); // Http://bugs.jqueryui.com/ticket/10140 - Resizable: Width calculation is wrong when containment element is "position: relative" // when containment element is immediate parent @@ -213,10 +214,10 @@ test( "containment - immediate parent", function() { } ); testHelper.drag( ".ui-resizable-e", 400, 0 ); - equal( element.width(), 300, "Relative, contained within container width" ); + assert.equal( element.width(), 300, "Relative, contained within container width" ); testHelper.drag( ".ui-resizable-s", 0, 400 ); - equal( element.height(), 300, "Relative, contained within container height" ); + assert.equal( element.height(), 300, "Relative, contained within container height" ); $( "#child" ).css( { left: 50, top: 50 } ); $( "#parent" ).css( { left: 50, top: 50 } ); @@ -228,56 +229,56 @@ test( "containment - immediate parent", function() { } ); testHelper.drag( ".ui-resizable-e", 400, 0 ); - equal( element.width(), 250, "Relative with Left, contained within container width" ); + assert.equal( element.width(), 250, "Relative with Left, contained within container width" ); testHelper.drag( ".ui-resizable-s", 0, 400 ); - equal( element.height(), 250, "Relative with Top, contained within container height" ); + assert.equal( element.height(), 250, "Relative with Top, contained within container height" ); } ); -test( "grid", function() { - expect( 4 ); +QUnit.test( "grid", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: [ 0, 20 ] } ); testHelper.drag( handle, 3, 9 ); - equal( target.width(), 103, "compare width" ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.width(), 103, "compare width" ); + assert.equal( target.height(), 100, "compare height" ); testHelper.drag( handle, 15, 11 ); - equal( target.width(), 118, "compare width" ); - equal( target.height(), 120, "compare height" ); + assert.equal( target.width(), 118, "compare width" ); + assert.equal( target.height(), 120, "compare height" ); } ); -test( "grid (min/max dimensions)", function() { - expect( 4 ); +QUnit.test( "grid (min/max dimensions)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", grid: 20, minWidth: 65, minHeight: 65, maxWidth: 135, maxHeight: 135 } ); testHelper.drag( handle, 50, 50 ); - equal( target.width(), 120, "grid should respect maxWidth" ); - equal( target.height(), 120, "grid should respect maxHeight" ); + assert.equal( target.width(), 120, "grid should respect maxWidth" ); + assert.equal( target.height(), 120, "grid should respect maxHeight" ); testHelper.drag( handle, -100, -100 ); - equal( target.width(), 80, "grid should respect minWidth" ); - equal( target.height(), 80, "grid should respect minHeight" ); + assert.equal( target.width(), 80, "grid should respect minWidth" ); + assert.equal( target.height(), 80, "grid should respect minHeight" ); } ); -test( "grid (wrapped)", function() { - expect( 4 ); +QUnit.test( "grid (wrapped)", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-se", target = $( "#resizable2" ).resizable( { handles: "all", grid: [ 0, 20 ] } ); testHelper.drag( handle, 3, 9 ); - equal( target.width(), 103, "compare width" ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.width(), 103, "compare width" ); + assert.equal( target.height(), 100, "compare height" ); testHelper.drag( handle, 15, 11 ); - equal( target.width(), 118, "compare width" ); - equal( target.height(), 120, "compare height" ); + assert.equal( target.width(), 118, "compare width" ); + assert.equal( target.height(), 120, "compare height" ); } ); -test( "grid - Resizable: can be moved when grid option is set (#9611)", function() { - expect( 6 ); +QUnit.test( "grid - Resizable: can be moved when grid option is set (#9611)", function( assert ) { + assert.expect( 6 ); var oldPosition, handle = ".ui-resizable-nw", @@ -287,20 +288,20 @@ test( "grid - Resizable: can be moved when grid option is set (#9611)", function } ); testHelper.drag( handle, 50, 50 ); - equal( target.width(), 50, "compare width" ); - equal( target.height(), 50, "compare height" ); + assert.equal( target.width(), 50, "compare width" ); + assert.equal( target.height(), 50, "compare height" ); oldPosition = target.position(); testHelper.drag( handle, 50, 50 ); - equal( target.width(), 50, "compare width" ); - equal( target.height(), 50, "compare height" ); - equal( target.position().top, oldPosition.top, "compare top" ); - equal( target.position().left, oldPosition.left, "compare left" ); + assert.equal( target.width(), 50, "compare width" ); + assert.equal( target.height(), 50, "compare height" ); + assert.equal( target.position().top, oldPosition.top, "compare top" ); + assert.equal( target.position().left, oldPosition.left, "compare left" ); } ); -test( "grid - maintains grid with padding and border when approaching no dimensions", function() { - expect( 2 ); +QUnit.test( "grid - maintains grid with padding and border when approaching no dimensions", function( assert ) { + assert.expect( 2 ); // Http://bugs.jqueryui.com/ticket/10437 - Resizable: border with grid option working wrong var handle = ".ui-resizable-nw", @@ -315,103 +316,103 @@ test( "grid - maintains grid with padding and border when approaching no dimensi } ); testHelper.drag( handle, 50, 50 ); - equal( target.outerWidth(), 50, "compare width" ); - equal( target.outerHeight(), 52, "compare height" ); + assert.equal( target.outerWidth(), 50, "compare width" ); + assert.equal( target.outerHeight(), 52, "compare height" ); } ); -test( "ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { - expect( 4 ); +QUnit.test( "ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-se", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } ); testHelper.drag( handle, -50, -50 ); - equal( target.width(), 60, "compare minWidth" ); - equal( target.height(), 60, "compare minHeight" ); + assert.equal( target.width(), 60, "compare minWidth" ); + assert.equal( target.height(), 60, "compare minHeight" ); testHelper.drag( handle, 70, 70 ); - equal( target.width(), 100, "compare maxWidth" ); - equal( target.height(), 100, "compare maxHeight" ); + assert.equal( target.width(), 100, "compare maxWidth" ); + assert.equal( target.height(), 100, "compare maxHeight" ); } ); -test( "ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { - expect( 4 ); +QUnit.test( "ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-sw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } ); testHelper.drag( handle, 50, -50 ); - equal( target.width(), 60, "compare minWidth" ); - equal( target.height(), 60, "compare minHeight" ); + assert.equal( target.width(), 60, "compare minWidth" ); + assert.equal( target.height(), 60, "compare minHeight" ); testHelper.drag( handle, -70, 70 ); - equal( target.width(), 100, "compare maxWidth" ); - equal( target.height(), 100, "compare maxHeight" ); + assert.equal( target.width(), 100, "compare maxWidth" ); + assert.equal( target.height(), 100, "compare maxHeight" ); } ); -test( "ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { - expect( 4 ); +QUnit.test( "ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-ne", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } ); testHelper.drag( handle, -50, 50 ); - equal( target.width(), 60, "compare minWidth" ); - equal( target.height(), 60, "compare minHeight" ); + assert.equal( target.width(), 60, "compare minWidth" ); + assert.equal( target.height(), 60, "compare minHeight" ); testHelper.drag( handle, 70, -70 ); - equal( target.width(), 100, "compare maxWidth" ); - equal( target.height(), 100, "compare maxHeight" ); + assert.equal( target.width(), 100, "compare maxWidth" ); + assert.equal( target.height(), 100, "compare maxHeight" ); } ); -test( "ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() { - expect( 4 ); +QUnit.test( "ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function( assert ) { + assert.expect( 4 ); var handle = ".ui-resizable-nw", target = $( "#resizable1" ).resizable( { handles: "all", minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 } ); testHelper.drag( handle, 70, 70 ); - equal( target.width(), 60, "compare minWidth" ); - equal( target.height(), 60, "compare minHeight" ); + assert.equal( target.width(), 60, "compare minWidth" ); + assert.equal( target.height(), 60, "compare minHeight" ); testHelper.drag( handle, -70, -70 ); - equal( target.width(), 100, "compare maxWidth" ); - equal( target.height(), 100, "compare maxHeight" ); + assert.equal( target.width(), 100, "compare maxWidth" ); + assert.equal( target.height(), 100, "compare maxHeight" ); } ); -test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }", function() { - expect( 2 ); +QUnit.test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }", function( assert ) { + assert.expect( 2 ); var handle = "#resizer1", target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" ) }, containment: "parent" } ); testHelper.drag( handle, 0, 70 ); - equal( target.height(), 170, "compare height" ); + assert.equal( target.height(), 170, "compare height" ); testHelper.drag( handle, 0, -70 ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.height(), 100, "compare height" ); } ); -test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' }", function() { - expect( 2 ); +QUnit.test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' }", function( assert ) { + assert.expect( 2 ); var handle = "#resizer1", target = $( "#resizable1" ).resizable( { handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" } ); testHelper.drag( handle, 0, 70 ); - equal( target.height(), 170, "compare height" ); + assert.equal( target.height(), 170, "compare height" ); testHelper.drag( handle, 0, -70 ); - equal( target.height(), 100, "compare height" ); + assert.equal( target.height(), 100, "compare height" ); } ); -test( "zIndex, applied to all handles", function() { - expect( 8 ); +QUnit.test( "zIndex, applied to all handles", function( assert ) { + assert.expect( 8 ); var target = $( "
" ).resizable( { handles: "all", zIndex: 100 } ); target.children( ".ui-resizable-handle" ).each( function( index, handle ) { - equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" ); + assert.equal( $( handle ).css( "zIndex" ), 100, "compare zIndex" ); } ); } ); -test( "setOption handles", function() { - expect( 11 ); +QUnit.test( "setOption handles", function( assert ) { + assert.expect( 11 ); var target = $( "
" ).resizable(); @@ -422,9 +423,9 @@ test( "setOption handles", function() { var handles = target.find( ".ui-resizable-handle" ); - equal( handles.length, expectedHandles.length, "Correct number of handles found" ); + assert.equal( handles.length, expectedHandles.length, "Correct number of handles found" ); $.each( expectedHandles, function( index, handleClass ) { - equal( handles.filter( handleClass ).length, 1, "Found " + handleClass ); + assert.equal( handles.filter( handleClass ).length, 1, "Found " + handleClass ); } ); } @@ -437,8 +438,8 @@ test( "setOption handles", function() { checkHandles( [ "s", "w" ] ); } ); -test( "alsoResize + containment", function() { - expect( 4 ); +QUnit.test( "alsoResize + containment", function( assert ) { + assert.expect( 4 ); var other = $( "
" ) .css( { width: 50, @@ -451,14 +452,14 @@ test( "alsoResize + containment", function() { } ); testHelper.drag( ".ui-resizable-se", 400, 400 ); - equal( element.width(), 300, "resizable constrained width 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.height(), 150, "alsoResize constrained height at containment edge" ); + assert.equal( element.width(), 300, "resizable constrained width at containment edge" ); + assert.equal( element.height(), 200, "resizable constrained height at containment edge" ); + assert.equal( other.width(), 250, "alsoResize constrained width at containment edge" ); + assert.equal( other.height(), 150, "alsoResize constrained height at containment edge" ); } ); -test( "alsoResize + multiple selection", function() { - expect( 6 ); +QUnit.test( "alsoResize + multiple selection", function( assert ) { + assert.expect( 6 ); var other1 = $( "
" ) .addClass( "other" ) .css( { @@ -479,12 +480,12 @@ test( "alsoResize + multiple selection", function() { } ); testHelper.drag( ".ui-resizable-se", 400, 400 ); - equal( element.width(), 300, "resizable constrained width 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.height(), 150, "alsoResize o1 constrained height at containment edge" ); - equal( other2.width(), 250, "alsoResize o2 constrained width at containment edge" ); - equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" ); + assert.equal( element.width(), 300, "resizable constrained width at containment edge" ); + assert.equal( element.height(), 200, "resizable constrained height at containment edge" ); + assert.equal( other1.width(), 250, "alsoResize o1 constrained width at containment edge" ); + assert.equal( other1.height(), 150, "alsoResize o1 constrained height at containment edge" ); + assert.equal( other2.width(), 250, "alsoResize o2 constrained width at containment edge" ); + assert.equal( other2.height(), 150, "alsoResize o2 constrained height at containment edge" ); } ); } ); -- 2.39.5