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 = $( "