diff options
Diffstat (limited to 'tests')
43 files changed, 634 insertions, 589 deletions
diff --git a/tests/unit/accordion/accordion_core.js b/tests/unit/accordion/accordion_core.js index 474943098..bd3b56752 100644 --- a/tests/unit/accordion/accordion_core.js +++ b/tests/unit/accordion/accordion_core.js @@ -2,10 +2,10 @@ define( [ "jquery", "./accordion_test_helpers", "ui/accordion" -], function( $, accordionTestHelper ) { +], function( $, testHelper ) { -var setupTeardown = accordionTestHelper.setupTeardown, - state = accordionTestHelper.state; +var setupTeardown = testHelper.setupTeardown, + state = testHelper.state; module( "accordion: core", setupTeardown() ); diff --git a/tests/unit/accordion/accordion_events.js b/tests/unit/accordion/accordion_events.js index 05dc144b4..ac05df30d 100644 --- a/tests/unit/accordion/accordion_events.js +++ b/tests/unit/accordion/accordion_events.js @@ -2,10 +2,10 @@ define( [ "jquery", "./accordion_test_helpers", "ui/accordion" -], function( $, accordionTestHelper ) { +], function( $, testHelper ) { -var setupTeardown = accordionTestHelper.setupTeardown, - state = accordionTestHelper.state; +var setupTeardown = testHelper.setupTeardown, + state = testHelper.state; module( "accordion: events", setupTeardown() ); diff --git a/tests/unit/accordion/accordion_methods.js b/tests/unit/accordion/accordion_methods.js index 5fdb115c6..f33996c36 100644 --- a/tests/unit/accordion/accordion_methods.js +++ b/tests/unit/accordion/accordion_methods.js @@ -2,11 +2,11 @@ define( [ "jquery", "./accordion_test_helpers", "ui/accordion" -], function( $, accordionTestHelper ) { +], function( $, testHelper ) { -var equalHeight = accordionTestHelper.equalHeight, - setupTeardown = accordionTestHelper.setupTeardown, - state = accordionTestHelper.state; +var equalHeight = testHelper.equalHeight, + setupTeardown = testHelper.setupTeardown, + state = testHelper.state; module( "accordion: methods", setupTeardown() ); diff --git a/tests/unit/accordion/accordion_options.js b/tests/unit/accordion/accordion_options.js index 3235057dc..d33241dac 100644 --- a/tests/unit/accordion/accordion_options.js +++ b/tests/unit/accordion/accordion_options.js @@ -2,11 +2,11 @@ define( [ "jquery", "./accordion_test_helpers", "ui/accordion" -], function( $, accordionTestHelper ) { +], function( $, testHelper ) { -var equalHeight = accordionTestHelper.equalHeight, - setupTeardown = accordionTestHelper.setupTeardown, - state = accordionTestHelper.state; +var equalHeight = testHelper.equalHeight, + setupTeardown = testHelper.setupTeardown, + state = testHelper.state; module( "accordion: options", setupTeardown() ); diff --git a/tests/unit/accordion/accordion_test_helpers.js b/tests/unit/accordion/accordion_test_helpers.js index ec1190f16..5eb3a4bc3 100644 --- a/tests/unit/accordion/accordion_test_helpers.js +++ b/tests/unit/accordion/accordion_test_helpers.js @@ -1,6 +1,10 @@ -define( function() { +define( [ + "jquery", + "lib/helper", + "ui/accordion" +], function( $, helper ) { -return { +return $.extend( helper, { equalHeight: function( accordion, height ) { accordion.find( ".ui-accordion-content" ).each(function() { equal( $( this ).outerHeight(), height ); @@ -26,7 +30,6 @@ return { }).get(); QUnit.push( QUnit.equiv(actual, expected), actual, expected ); } - -}; +} ); } ); diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index 3ed4b9487..a1e75848a 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -4,7 +4,7 @@ define( [ "./datepicker_test_helpers", "ui/datepicker", "ui/i18n/datepicker-he" -], function( $, common, datepickerTestHelpers ) { +], function( $, common, testHelper ) { module( "datepicker: core", { setup: function() { @@ -39,11 +39,11 @@ test("widget method", function() { asyncTest( "baseStructure", function() { expect( 58 ); var header, title, table, thead, week, panel, inl, child, - inp = datepickerTestHelpers.initNewInput(), + inp = testHelper.initNewInput(), dp = $( "#ui-datepicker-div" ); function step1() { - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { ok( dp.is( ":visible" ), "Structure - datepicker visible" ); ok( !dp.is( ".ui-datepicker-rtl" ), "Structure - not right-to-left" ); ok( !dp.is( ".ui-datepicker-multi" ), "Structure - not multi-month" ); @@ -84,12 +84,12 @@ asyncTest( "baseStructure", function() { function step2() { // Editable month/year and button panel - inp = datepickerTestHelpers.initNewInput({ + inp = testHelper.initNewInput({ changeMonth: true, changeYear: true, showButtonPanel: true }); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { title = dp.find( "div.ui-datepicker-title" ); ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure - month selector" ); ok( title.children( ":last" ).is( "select.ui-datepicker-year" ), "Structure - year selector" ); @@ -107,8 +107,8 @@ asyncTest( "baseStructure", function() { function step3() { // Multi-month 2 - inp = datepickerTestHelpers.initNewInput({ numberOfMonths: 2 }); - datepickerTestHelpers.onFocus( inp, function() { + inp = testHelper.initNewInput({ numberOfMonths: 2 }); + testHelper.onFocus( inp, function() { ok( dp.is( ".ui-datepicker-multi" ), "Structure multi [2] - multi-month" ); equal( dp.children().length, 3, "Structure multi [2] - child count" ); @@ -129,8 +129,8 @@ asyncTest( "baseStructure", function() { function step4() { // Multi-month 3 - inp = datepickerTestHelpers.initNewInput({ numberOfMonths: 3 }); - datepickerTestHelpers.onFocus( inp, function() { + inp = testHelper.initNewInput({ numberOfMonths: 3 }); + testHelper.onFocus( inp, function() { ok( dp.is( ".ui-datepicker-multi-3" ), "Structure multi [3] - multi-3" ); ok( !dp.is( ".ui-datepicker-multi-2" ), "Structure multi [3] - Trac #6704" ); @@ -141,8 +141,8 @@ asyncTest( "baseStructure", function() { function step5() { // Multi-month [2, 2] - inp = datepickerTestHelpers.initNewInput({ numberOfMonths: [ 2, 2 ] }); - datepickerTestHelpers.onFocus( inp, function() { + inp = testHelper.initNewInput({ numberOfMonths: [ 2, 2 ] }); + testHelper.onFocus( inp, function() { ok( dp.is( ".ui-datepicker-multi" ), "Structure multi - multi-month" ); equal( dp.children().length, 6, "Structure multi [2,2] - child count" ); @@ -167,7 +167,7 @@ asyncTest( "baseStructure", function() { inp.datepicker( "hide" ).datepicker( "destroy" ); // Inline - inl = datepickerTestHelpers.init( "#inl" ); + inl = testHelper.init( "#inl" ); dp = inl.children(); ok( dp.is( ".ui-datepicker-inline" ), "Structure inline - main div" ); @@ -187,7 +187,7 @@ asyncTest( "baseStructure", function() { inl.datepicker( "destroy" ); // Inline multi-month - inl = datepickerTestHelpers.init( "#inl", { numberOfMonths: 2 } ); + inl = testHelper.init( "#inl", { numberOfMonths: 2 } ); dp = inl.children(); ok( dp.is( ".ui-datepicker-inline" ) && dp.is( ".ui-datepicker-multi" ), "Structure inline multi - main div" ); @@ -213,13 +213,13 @@ asyncTest( "baseStructure", function() { asyncTest( "customStructure", function() { expect( 20 ); var header, panel, title, thead, - inp = datepickerTestHelpers.initNewInput( $.datepicker.regional.he ), + inp = testHelper.initNewInput( $.datepicker.regional.he ), dp = $( "#ui-datepicker-div" ); function step1() { inp.datepicker( "option", "showButtonPanel", true ); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { ok( dp.is( ".ui-datepicker-rtl" ), "Structure RTL - right-to-left" ); header = dp.children( ":first" ); @@ -241,14 +241,14 @@ asyncTest( "customStructure", function() { // Hide prev/next function step2() { - inp = datepickerTestHelpers.initNewInput({ + inp = testHelper.initNewInput({ hideIfNoPrevNext: true, minDate: new Date( 2008, 2 - 1, 4 ), maxDate: new Date( 2008, 2 - 1, 14 ) }); inp.val( "02/10/2008" ); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { header = dp.children( ":first" ); ok( header.is( "div.ui-datepicker-header" ), "Structure hide prev/next - header division" ); equal( header.children().length, 1, "Structure hide prev/next - links child count" ); @@ -261,9 +261,9 @@ asyncTest( "customStructure", function() { // Changeable Month with read-only year function step3() { - inp = datepickerTestHelpers.initNewInput({ changeMonth: true }); + inp = testHelper.initNewInput({ changeMonth: true }); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { title = dp.children( ":first" ).children( ":last" ); equal( title.children().length, 2, "Structure changeable month - title child count" ); ok( title.children( ":first" ).is( "select.ui-datepicker-month" ), "Structure changeable month - month selector" ); @@ -276,9 +276,9 @@ asyncTest( "customStructure", function() { // Changeable year with read-only month function step4() { - inp = datepickerTestHelpers.initNewInput({ changeYear: true }); + inp = testHelper.initNewInput({ changeYear: true }); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { title = dp.children( ":first" ).children( ":last" ); equal( title.children().length, 2, "Structure changeable year - title child count" ); ok( title.children( ":first" ).is( "span.ui-datepicker-month" ), "Structure changeable year - read-only month" ); @@ -291,9 +291,9 @@ asyncTest( "customStructure", function() { // Read-only first day of week function step5() { - inp = datepickerTestHelpers.initNewInput({ changeFirstDay: false }); + inp = testHelper.initNewInput({ changeFirstDay: false }); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { thead = dp.find( ".ui-datepicker-calendar thead tr" ); equal( thead.children().length, 7, "Structure read-only first day - thead child count" ); equal( thead.find( "a" ).length, 0, "Structure read-only first day - thead links count" ); @@ -311,19 +311,19 @@ asyncTest( "customStructure", function() { test("keystrokes", function() { expect( 26 ); - var inp = datepickerTestHelpers.init("#inp"), + var inp = testHelper.init("#inp"), date = new Date(); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke enter"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke enter"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), "Keystroke enter - preset"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+home"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+home"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END}); ok(inp.datepicker("getDate") == null, "Keystroke ctrl+end"); @@ -332,95 +332,95 @@ test("keystrokes", function() { ok(inp.datepicker("getDate") == null, "Keystroke esc"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), "Keystroke esc - preset"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), "Keystroke esc - abandoned"); // Moving by day or week inp.val("").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.LEFT}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+left"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+left"); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.LEFT}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke left"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke left"); inp.val("").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.RIGHT}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+right"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+right"); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.RIGHT}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke right"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke right"); inp.val("").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 7); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+up"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+up"); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 7); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke up"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke up"); inp.val("").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 7); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+down"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+down"); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 7); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke down"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Keystroke down"); // Moving by month or year inp.val("02/04/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 4), "Keystroke pgup"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 4), "Keystroke pgdn"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 4), "Keystroke ctrl+pgup"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 4), "Keystroke ctrl+pgdn"); // Check for moving to short months inp.val("03/31/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29), "Keystroke pgup - Feb"); inp.val("01/30/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29), "Keystroke pgdn - Feb"); inp.val("02/29/2008").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 28), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 28), "Keystroke ctrl+pgup - Feb"); inp.val("02/29/2008").datepicker("show"). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 28), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 28), "Keystroke ctrl+pgdn - Feb"); // Goto current inp.datepicker("option", {gotoCurrent: true}). @@ -428,35 +428,35 @@ test("keystrokes", function() { simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.HOME}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), "Keystroke ctrl+home"); // Change steps inp.datepicker("option", {stepMonths: 2, gotoCurrent: false}). datepicker("hide").val("02/04/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2007, 12 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2007, 12 - 1, 4), "Keystroke pgup step 2"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 4 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 4 - 1, 4), "Keystroke pgdn step 2"); }); test("mouse", function() { expect( 15 ); var inl, - inp = datepickerTestHelpers.init("#inp"), + inp = testHelper.init("#inp"), dp = $("#ui-datepicker-div"), date = new Date(); inp.val("").datepicker("show"); $(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {}); date.setDate(10); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Mouse click"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Mouse click"); inp.val("02/04/2008").datepicker("show"); $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 12), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click - preset"); inp.val("02/04/2008").datepicker("show"); inp.val("").datepicker("show"); @@ -464,66 +464,66 @@ test("mouse", function() { ok(inp.datepicker("getDate") == null, "Mouse click - close"); inp.val("02/04/2008").datepicker("show"); $("button.ui-datepicker-close", dp).simulate("click", {}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), "Mouse click - close + preset"); inp.val("02/04/2008").datepicker("show"); $("a.ui-datepicker-prev", dp).simulate("click", {}); $("button.ui-datepicker-close", dp).simulate("click", {}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), "Mouse click - abandoned"); // Current/previous/next inp.val("02/04/2008").datepicker("option", {showButtonPanel: true}).datepicker("show"); $(".ui-datepicker-current", dp).simulate("click", {}); $(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {}); date.setDate(14); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Mouse click - current"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Mouse click - current"); inp.val("02/04/2008").datepicker("show"); $(".ui-datepicker-prev", dp).simulate("click"); $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click"); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 16), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 16), "Mouse click - previous"); inp.val("02/04/2008").datepicker("show"); $(".ui-datepicker-next", dp).simulate("click"); $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click"); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 18), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 18), "Mouse click - next"); // Previous/next with minimum/maximum inp.datepicker("option", {minDate: new Date(2008, 2 - 1, 2), maxDate: new Date(2008, 2 - 1, 26)}).val("02/04/2008").datepicker("show"); $(".ui-datepicker-prev", dp).simulate("click"); $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click"); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 16), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 16), "Mouse click - previous + min/max"); inp.val("02/04/2008").datepicker("show"); $(".ui-datepicker-next", dp).simulate("click"); $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click"); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 18), + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 18), "Mouse click - next + min/max"); // Inline - inl = datepickerTestHelpers.init("#inl"); + inl = testHelper.init("#inl"); dp = $(".ui-datepicker-inline", inl); date = new Date(); inl.datepicker("setDate", date); $(".ui-datepicker-calendar tbody a:contains(10)", dp).simulate("click", {}); date.setDate(10); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline"); + testHelper.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline"); inl.datepicker("option", {showButtonPanel: true}).datepicker("setDate", new Date(2008, 2 - 1, 4)); $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {}); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click inline - preset"); + testHelper.equalsDate(inl.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click inline - preset"); inl.datepicker("option", {showButtonPanel: true}); $(".ui-datepicker-current", dp).simulate("click", {}); $(".ui-datepicker-calendar tbody a:contains(14)", dp).simulate("click", {}); date.setDate(14); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline - current"); + testHelper.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline - current"); inl.datepicker("setDate", new Date(2008, 2 - 1, 4)); $(".ui-datepicker-prev", dp).simulate("click"); $(".ui-datepicker-calendar tbody a:contains(16)", dp).simulate("click"); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), new Date(2008, 1 - 1, 16), + testHelper.equalsDate(inl.datepicker("getDate"), new Date(2008, 1 - 1, 16), "Mouse click inline - previous"); inl.datepicker("setDate", new Date(2008, 2 - 1, 4)); $(".ui-datepicker-next", dp).simulate("click"); $(".ui-datepicker-calendar tbody a:contains(18)", dp).simulate("click"); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), new Date(2008, 3 - 1, 18), + testHelper.equalsDate(inl.datepicker("getDate"), new Date(2008, 3 - 1, 18), "Mouse click inline - next"); }); diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js index b012f647d..04a4cbfe8 100644 --- a/tests/unit/datepicker/datepicker_events.js +++ b/tests/unit/datepicker/datepicker_events.js @@ -2,7 +2,7 @@ define( [ "jquery", "./datepicker_test_helpers", "ui/datepicker" -], function( $, datepickerTestHelpers ) { +], function( $, testHelper ) { module("datepicker: events"); @@ -25,13 +25,13 @@ function callback2(year, month, inst) { test("events", function() { expect( 26 ); var dateStr, newMonthYear, inp2, - inp = datepickerTestHelpers.init("#inp", {onSelect: callback}), + inp = testHelper.init("#inp", {onSelect: callback}), date = new Date(); // onSelect inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); equal(selectedThis, inp[0], "Callback selected this"); - equal(selectedInst, $.data(inp[0], datepickerTestHelpers.PROP_NAME), "Callback selected inst"); + equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback selected inst"); equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date), "Callback selected date"); inp.val("").datepicker("show"). @@ -60,7 +60,7 @@ test("events", function() { inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_UP}); date.setMonth(date.getMonth() - 1); equal(selectedThis, inp[0], "Callback change month/year this"); - equal(selectedInst, $.data(inp[0], datepickerTestHelpers.PROP_NAME), "Callback change month/year inst"); + equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback change month/year inst"); equal(selectedDate, newMonthYear(date), "Callback change month/year date - pgup"); inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}); @@ -108,7 +108,7 @@ test("events", function() { val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE}); equal(selectedThis, inp[0], "Callback close this"); - equal(selectedInst, $.data(inp[0], datepickerTestHelpers.PROP_NAME), "Callback close inst"); + equal(selectedInst, $.data(inp[0], testHelper.PROP_NAME), "Callback close inst"); equal(selectedDate, "", "Callback close date - esc"); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); @@ -121,7 +121,7 @@ test("events", function() { simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END}); equal(selectedDate, "", "Callback close date - ctrl+end"); - inp2 = datepickerTestHelpers.init("#inp2"); + inp2 = testHelper.init("#inp2"); inp2.datepicker().datepicker("option", {onClose: callback}).datepicker("show"); inp.datepicker("show"); equal(selectedThis, inp2[0], "Callback close this"); @@ -129,7 +129,7 @@ test("events", function() { test("beforeShowDay-getDate", function() { expect( 3 ); - var inp = datepickerTestHelpers.init("#inp", {beforeShowDay: function() { inp.datepicker("getDate"); return [true, ""]; }}), + var inp = testHelper.init("#inp", {beforeShowDay: function() { inp.datepicker("getDate"); return [true, ""]; }}), dp = $("#ui-datepicker-div"); inp.val("01/01/2010").datepicker("show"); // contains non-breaking space diff --git a/tests/unit/datepicker/datepicker_methods.js b/tests/unit/datepicker/datepicker_methods.js index c16376880..3899779a9 100644 --- a/tests/unit/datepicker/datepicker_methods.js +++ b/tests/unit/datepicker/datepicker_methods.js @@ -2,72 +2,72 @@ define( [ "jquery", "./datepicker_test_helpers", "ui/datepicker" -], function( $, datepickerTestHelpers ) { +], function( $, testHelper ) { module("datepicker: methods"); test("destroy", function() { expect( 33 ); var inl, - inp = datepickerTestHelpers.init("#inp"); + inp = testHelper.init("#inp"); ok(inp.is(".hasDatepicker"), "Default - marker class set"); - ok($.data(inp[0], datepickerTestHelpers.PROP_NAME), "Default - instance present"); + ok($.data(inp[0], testHelper.PROP_NAME), "Default - instance present"); ok(inp.next().is("#alt"), "Default - button absent"); inp.datepicker("destroy"); inp = $("#inp"); ok(!inp.is(".hasDatepicker"), "Default - marker class cleared"); - ok(!$.data(inp[0], datepickerTestHelpers.PROP_NAME), "Default - instance absent"); + ok(!$.data(inp[0], testHelper.PROP_NAME), "Default - instance absent"); ok(inp.next().is("#alt"), "Default - button absent"); // With button - inp= datepickerTestHelpers.init("#inp", {showOn: "both"}); + inp= testHelper.init("#inp", {showOn: "both"}); ok(inp.is(".hasDatepicker"), "Button - marker class set"); - ok($.data(inp[0], datepickerTestHelpers.PROP_NAME), "Button - instance present"); + ok($.data(inp[0], testHelper.PROP_NAME), "Button - instance present"); ok(inp.next().text() === "...", "Button - button added"); inp.datepicker("destroy"); inp = $("#inp"); ok(!inp.is(".hasDatepicker"), "Button - marker class cleared"); - ok(!$.data(inp[0], datepickerTestHelpers.PROP_NAME), "Button - instance absent"); + ok(!$.data(inp[0], testHelper.PROP_NAME), "Button - instance absent"); ok(inp.next().is("#alt"), "Button - button removed"); // With append text - inp = datepickerTestHelpers.init("#inp", {appendText: "Testing"}); + inp = testHelper.init("#inp", {appendText: "Testing"}); ok(inp.is(".hasDatepicker"), "Append - marker class set"); - ok($.data(inp[0], datepickerTestHelpers.PROP_NAME), "Append - instance present"); + ok($.data(inp[0], testHelper.PROP_NAME), "Append - instance present"); ok(inp.next().text() === "Testing", "Append - append text added"); inp.datepicker("destroy"); inp = $("#inp"); ok(!inp.is(".hasDatepicker"), "Append - marker class cleared"); - ok(!$.data(inp[0], datepickerTestHelpers.PROP_NAME), "Append - instance absent"); + ok(!$.data(inp[0], testHelper.PROP_NAME), "Append - instance absent"); ok(inp.next().is("#alt"), "Append - append text removed"); // With both - inp= datepickerTestHelpers.init("#inp", {showOn: "both", buttonImageOnly: true, + inp= testHelper.init("#inp", {showOn: "both", buttonImageOnly: true, buttonImage: "images/calendar.gif", appendText: "Testing"}); ok(inp.is(".hasDatepicker"), "Both - marker class set"); - ok($.data(inp[0], datepickerTestHelpers.PROP_NAME), "Both - instance present"); + ok($.data(inp[0], testHelper.PROP_NAME), "Both - instance present"); ok(inp.next()[0].nodeName.toLowerCase() === "img", "Both - button added"); ok(inp.next().next().text() === "Testing", "Both - append text added"); inp.datepicker("destroy"); inp = $("#inp"); ok(!inp.is(".hasDatepicker"), "Both - marker class cleared"); - ok(!$.data(inp[0], datepickerTestHelpers.PROP_NAME), "Both - instance absent"); + ok(!$.data(inp[0], testHelper.PROP_NAME), "Both - instance absent"); ok(inp.next().is("#alt"), "Both - button and append text absent"); // Inline - inl = datepickerTestHelpers.init("#inl"); + inl = testHelper.init("#inl"); ok(inl.is(".hasDatepicker"), "Inline - marker class set"); ok(inl.html() !== "", "Inline - datepicker present"); - ok($.data(inl[0], datepickerTestHelpers.PROP_NAME), "Inline - instance present"); + ok($.data(inl[0], testHelper.PROP_NAME), "Inline - instance present"); ok(inl.next().length === 0 || inl.next().is("p"), "Inline - button absent"); inl.datepicker("destroy"); inl = $("#inl"); ok(!inl.is(".hasDatepicker"), "Inline - marker class cleared"); ok(inl.html() === "", "Inline - datepicker absent"); - ok(!$.data(inl[0], datepickerTestHelpers.PROP_NAME), "Inline - instance absent"); + ok(!$.data(inl[0], testHelper.PROP_NAME), "Inline - instance absent"); ok(inl.next().length === 0 || inl.next().is("p"), "Inline - button absent"); }); test("enableDisable", function() { expect( 33 ); var inl, dp, - inp = datepickerTestHelpers.init("#inp"); + inp = testHelper.init("#inp"); ok(!inp.datepicker("isDisabled"), "Enable/disable - initially marked as enabled"); ok(!inp[0].disabled, "Enable/disable - field initially enabled"); inp.datepicker("disable"); @@ -78,7 +78,7 @@ test("enableDisable", function() { ok(!inp[0].disabled, "Enable/disable - field now enabled"); inp.datepicker("destroy"); // With a button - inp = datepickerTestHelpers.init("#inp", {showOn: "button"}); + inp = testHelper.init("#inp", {showOn: "button"}); ok(!inp.datepicker("isDisabled"), "Enable/disable button - initially marked as enabled"); ok(!inp[0].disabled, "Enable/disable button - field initially enabled"); ok(!inp.next("button")[0].disabled, "Enable/disable button - button initially enabled"); @@ -92,7 +92,7 @@ test("enableDisable", function() { ok(!inp.next("button")[0].disabled, "Enable/disable button - button now enabled"); inp.datepicker("destroy"); // With an image button - inp = datepickerTestHelpers.init("#inp", {showOn: "button", buttonImageOnly: true, + inp = testHelper.init("#inp", {showOn: "button", buttonImageOnly: true, buttonImage: "images/calendar.gif"}); ok(!inp.datepicker("isDisabled"), "Enable/disable image - initially marked as enabled"); ok(!inp[0].disabled, "Enable/disable image - field initially enabled"); @@ -107,7 +107,7 @@ test("enableDisable", function() { ok(parseFloat(inp.next("img").css("opacity")) === 1, "Enable/disable image - image now enabled"); inp.datepicker("destroy"); // Inline - inl = datepickerTestHelpers.init("#inl", {changeYear: true}); + inl = testHelper.init("#inl", {changeYear: true}); dp = $(".ui-datepicker-inline", inl); ok(!inl.datepicker("isDisabled"), "Enable/disable inline - initially marked as enabled"); ok(!dp.children().is(".ui-state-disabled"), "Enable/disable inline - not visually disabled initially"); diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 20a7b4d80..ee4a3bae4 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -5,13 +5,13 @@ define( [ "ui/i18n/datepicker-fr", "ui/i18n/datepicker-he", "ui/i18n/datepicker-zh-CN" -], function( $, datepickerTestHelpers ) { +], function( $, testHelper ) { module("datepicker: options"); test("setDefaults", function() { expect( 3 ); - datepickerTestHelpers.init("#inp"); + testHelper.init("#inp"); equal($.datepicker._defaults.showOn, "focus", "Initial showOn"); $.datepicker.setDefaults({showOn: "button"}); equal($.datepicker._defaults.showOn, "button", "Change default showOn"); @@ -21,8 +21,8 @@ test("setDefaults", function() { test("option", function() { expect( 17 ); - var inp = datepickerTestHelpers.init("#inp"), - inst = $.data(inp[0], datepickerTestHelpers.PROP_NAME); + var inp = testHelper.init("#inp"), + inst = $.data(inp[0], testHelper.PROP_NAME); // Set option equal(inst.settings.showOn, null, "Initial setting showOn"); equal($.datepicker._get(inst, "showOn"), "focus", "Initial instance showOn"); @@ -40,7 +40,7 @@ test("option", function() { equal($.datepicker._get(inst, "showOn"), "focus", "Restore instance showOn"); equal($.datepicker._defaults.showOn, "focus", "Retain default showOn"); // Get option - inp = datepickerTestHelpers.init("#inp"); + inp = testHelper.init("#inp"); equal(inp.datepicker("option", "showOn"), "focus", "Initial setting showOn"); inp.datepicker("option", "showOn", "button"); equal(inp.datepicker("option", "showOn"), "button", "Change instance showOn"); @@ -53,7 +53,7 @@ test("option", function() { test( "disabled", function() { expect(8); - var inp = datepickerTestHelpers.init("#inp"); + var inp = testHelper.init("#inp"); ok(!inp.datepicker("isDisabled"), "Initially marked as enabled"); ok(!inp[0].disabled, "Field initially enabled"); inp.datepicker("option", "disabled", true); @@ -64,15 +64,15 @@ test( "disabled", function() { ok(!inp[0].disabled, "Field now enabled"); inp.datepicker("destroy"); - inp = datepickerTestHelpers.init("#inp", { disabled: true }); + inp = testHelper.init("#inp", { disabled: true }); ok(inp.datepicker("isDisabled"), "Initially marked as disabled"); ok(inp[0].disabled, "Field initially disabled"); }); test("change", function() { expect( 12 ); - var inp = datepickerTestHelpers.init("#inp"), - inst = $.data(inp[0], datepickerTestHelpers.PROP_NAME); + var inp = testHelper.init("#inp"), + inst = $.data(inp[0], testHelper.PROP_NAME); equal(inst.settings.showOn, null, "Initial setting showOn"); equal($.datepicker._get(inst, "showOn"), "focus", "Initial instance showOn"); equal($.datepicker._defaults.showOn, "focus", "Initial default showOn"); @@ -107,7 +107,7 @@ test("change", function() { expect( isOldIE ? 25 : 29 ); function step0() { - var inp = datepickerTestHelpers.initNewInput(), + var inp = testHelper.initNewInput(), dp = $( "#ui-datepicker-div" ); button = inp.siblings( "button" ); @@ -115,7 +115,7 @@ test("change", function() { image = inp.siblings( "img" ); ok( image.length === 0, "Focus - image absent" ); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { ok( dp.is( ":visible" ), "Focus - rendered on focus" ); inp.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } ); ok( !dp.is( ":visible" ), "Focus - hidden on exit" ); @@ -125,10 +125,10 @@ test("change", function() { function step1() { - var inp = datepickerTestHelpers.initNewInput(), + var inp = testHelper.initNewInput(), dp = $( "#ui-datepicker-div" ); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { ok( dp.is( ":visible" ), "Focus - rendered on focus" ); body.simulate( "mousedown", {} ); ok( !dp.is( ":visible" ), "Focus - hidden on external click" ); @@ -139,7 +139,7 @@ test("change", function() { } function step2() { - var inp = datepickerTestHelpers.initNewInput({ + var inp = testHelper.initNewInput({ showOn: "button", buttonText: "Popup" }), @@ -152,7 +152,7 @@ test("change", function() { ok( image.length === 0, "Button - image absent" ); equal( button.text(), "Popup", "Button - button text" ); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { ok( !dp.is( ":visible" ), "Button - not rendered on focus" ); button.click(); ok( dp.is( ":visible" ), "Button - rendered on button click" ); @@ -165,7 +165,7 @@ test("change", function() { } function step3() { - var inp = datepickerTestHelpers.initNewInput({ + var inp = testHelper.initNewInput({ showOn: "button", buttonImageOnly: true, buttonImage: "images/calendar.gif", @@ -181,7 +181,7 @@ test("change", function() { ok( /images\/calendar\.gif$/.test( image.attr( "src" ) ), "Image button - image source" ); equal( image.attr( "title" ), "Cal", "Image button - image text" ); - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { ok( !dp.is( ":visible" ), "Image button - not rendered on focus" ); image.click(); ok( dp.is( ":visible" ), "Image button - rendered on image click" ); @@ -194,7 +194,7 @@ test("change", function() { } function step4() { - var inp = datepickerTestHelpers.initNewInput({ + var inp = testHelper.initNewInput({ showOn: "both", buttonImage: "images/calendar.gif" }), @@ -210,7 +210,7 @@ test("change", function() { // TODO: This test occasionally fails to focus in IE8 in BrowserStack if ( !isOldIE ) { - datepickerTestHelpers.onFocus( inp, function() { + testHelper.onFocus( inp, function() { ok( dp.is( ":visible" ), "Both - rendered on focus" ); body.simulate( "mousedown", {} ); ok( !dp.is( ":visible" ), "Both - hidden on external click" ); @@ -233,7 +233,7 @@ test("change", function() { test("otherMonths", function() { expect( 8 ); - var inp = datepickerTestHelpers.init("#inp"), + var inp = testHelper.init("#inp"), pop = $("#ui-datepicker-div"); inp.val("06/01/2009").datepicker("show"); equal(pop.find("tbody").text(), @@ -261,105 +261,105 @@ test("otherMonths", function() { test("defaultDate", function() { expect( 16 ); - var inp = datepickerTestHelpers.init("#inp"), + var inp = testHelper.init("#inp"), date = new Date(); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date null"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date null"); // Numeric values inp.datepicker("option", {defaultDate: -2}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 2); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date -2"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2"); date = new Date(); inp.datepicker("option", {defaultDate: 3}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 3); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date 3"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 3"); date = new Date(); inp.datepicker("option", {defaultDate: 1 / "a"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date NaN"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date NaN"); // String offset values inp.datepicker("option", {defaultDate: "-1d"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() - 1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date -1d"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -1d"); inp.datepicker("option", {defaultDate: "+3D"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 4); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date +3D"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +3D"); inp.datepicker("option", {defaultDate: " -2 w "}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(); date.setDate(date.getDate() - 14); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date -2 w"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2 w"); inp.datepicker("option", {defaultDate: "+1 W"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setDate(date.getDate() + 21); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date +1 W"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1 W"); inp.datepicker("option", {defaultDate: " -1 m "}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - date = datepickerTestHelpers.addMonths(new Date(), -1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date -1 m"); + date = testHelper.addMonths(new Date(), -1); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -1 m"); inp.datepicker("option", {defaultDate: "+2M"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - date = datepickerTestHelpers.addMonths(new Date(), 2); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date +2M"); + date = testHelper.addMonths(new Date(), 2); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +2M"); inp.datepicker("option", {defaultDate: "-2y"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(); date.setFullYear(date.getFullYear() - 2); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date -2y"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2y"); inp.datepicker("option", {defaultDate: "+1 Y "}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date.setFullYear(date.getFullYear() + 3); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date +1 Y"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1 Y"); inp.datepicker("option", {defaultDate: "+1M +10d"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - date = datepickerTestHelpers.addMonths(new Date(), 1); + date = testHelper.addMonths(new Date(), 1); date.setDate(date.getDate() + 10); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date +1M +10d"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1M +10d"); // String date values inp.datepicker("option", {defaultDate: "07/04/2007"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(2007, 7 - 1, 4); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date 07/04/2007"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 07/04/2007"); inp.datepicker("option", {dateFormat: "yy-mm-dd", defaultDate: "2007-04-02"}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); date = new Date(2007, 4 - 1, 2); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date 2007-04-02"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 2007-04-02"); // Date value date = new Date(2007, 1 - 1, 26); inp.datepicker("option", {dateFormat: "mm/dd/yy", defaultDate: date}). datepicker("hide").val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Default date 01/26/2007"); + testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 01/26/2007"); }); test("miscellaneous", function() { expect( 19 ); var curYear, longNames, shortNames, date, dp = $("#ui-datepicker-div"), - inp = datepickerTestHelpers.init("#inp"); + inp = testHelper.init("#inp"); // Year range function genRange(start, offset) { var i = start, @@ -420,7 +420,7 @@ test("miscellaneous", function() { test("minMax", function() { expect( 23 ); var date, - inp = datepickerTestHelpers.init("#inp"), + inp = testHelper.init("#inp"), dp = $("#ui-datepicker-div"), lastYear = new Date(2007, 6 - 1, 4), nextYear = new Date(2009, 6 - 1, 4), @@ -429,45 +429,45 @@ test("minMax", function() { inp.val("06/04/2008").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), lastYear, + testHelper.equalsDate(inp.datepicker("getDate"), lastYear, "Min/max - null, null - ctrl+pgup"); inp.val("06/04/2008").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), nextYear, + testHelper.equalsDate(inp.datepicker("getDate"), nextYear, "Min/max - null, null - ctrl+pgdn"); inp.datepicker("option", {minDate: minDate}). datepicker("hide").val("06/04/2008").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, + testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - 02/29/2008, null - ctrl+pgup"); inp.val("06/04/2008").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), nextYear, + testHelper.equalsDate(inp.datepicker("getDate"), nextYear, "Min/max - 02/29/2008, null - ctrl+pgdn"); inp.datepicker("option", {maxDate: maxDate}). datepicker("hide").val("06/04/2008").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, + testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup"); inp.val("06/04/2008").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, + testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn"); inp.datepicker("option", {minDate: null}). datepicker("hide").val("06/04/2008").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), lastYear, + testHelper.equalsDate(inp.datepicker("getDate"), lastYear, "Min/max - null, 12/07/2008 - ctrl+pgup"); inp.val("06/04/2008").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, + testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - null, 12/07/2008 - ctrl+pgdn"); // Relative dates date = new Date(); @@ -476,31 +476,31 @@ test("minMax", function() { datepicker("hide").val("").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, + testHelper.equalsDate(inp.datepicker("getDate"), date, "Min/max - -1w, +1 M +10 D - ctrl+pgup"); - date = datepickerTestHelpers.addMonths(new Date(), 1); + date = testHelper.addMonths(new Date(), 1); date.setDate(date.getDate() + 10); inp.val("").datepicker("show"); inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, + testHelper.equalsDate(inp.datepicker("getDate"), date, "Min/max - -1w, +1 M +10 D - ctrl+pgdn"); // With existing date - inp = datepickerTestHelpers.init("#inp"); + inp = testHelper.init("#inp"); inp.val("06/04/2008").datepicker("option", {minDate: minDate}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min"); + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min"); inp.datepicker("option", {minDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); + testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); inp.datepicker("option", {minDate: null}).val("06/04/2008").datepicker("option", {maxDate: maxDate}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate < max"); + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate < max"); inp.datepicker("option", {maxDate: null}).val("01/04/2009").datepicker("option", {maxDate: maxDate}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); + testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); inp.datepicker("option", {maxDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); + testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); inp.datepicker("option", {maxDate: null}).val("06/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min, < max"); + testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min, < max"); inp.datepicker("option", {maxDate: null}).val("01/04/2009").datepicker("option", {minDate: minDate, maxDate: maxDate}); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); + testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); inp.datepicker("option", {yearRange: "-0:+1"}).val("01/01/" + new Date().getFullYear()); ok(dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - previous button disabled at 1/1/minYear"); @@ -527,50 +527,50 @@ test("minMax", function() { test("setDate", function() { expect( 24 ); var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone, - inp = datepickerTestHelpers.init("#inp"), + inp = testHelper.init("#inp"), date1 = new Date(2008, 6 - 1, 4), date2 = new Date(); ok(inp.datepicker("getDate") == null, "Set date - default"); inp.datepicker("setDate", date1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - 2008-06-04"); + testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - 2008-06-04"); date1 = new Date(); date1.setDate(date1.getDate() + 7); inp.datepicker("setDate", +7); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - +7"); + testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - +7"); date2.setFullYear(date2.getFullYear() + 2); inp.datepicker("setDate", "+2y"); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date2, "Set date - +2y"); + testHelper.equalsDate(inp.datepicker("getDate"), date2, "Set date - +2y"); inp.datepicker("setDate", date1, date2); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - two dates"); + testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - two dates"); inp.datepicker("setDate"); ok(inp.datepicker("getDate") == null, "Set date - null"); // Relative to current date date1 = new Date(); date1.setDate(date1.getDate() + 7); inp.datepicker("setDate", "c +7"); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - c +7"); + testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c +7"); date1.setDate(date1.getDate() + 7); inp.datepicker("setDate", "c+7"); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - c+7"); + testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c+7"); date1.setDate(date1.getDate() - 21); inp.datepicker("setDate", "c -3 w"); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - c -3 w"); + testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c -3 w"); // Inline - inl = datepickerTestHelpers.init("#inl"); + inl = testHelper.init("#inl"); date1 = new Date(2008, 6 - 1, 4); date2 = new Date(); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - default"); + testHelper.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - default"); inl.datepicker("setDate", date1); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - 2008-06-04"); + testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - 2008-06-04"); date1 = new Date(); date1.setDate(date1.getDate() + 7); inl.datepicker("setDate", +7); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - +7"); + testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - +7"); date2.setFullYear(date2.getFullYear() + 2); inl.datepicker("setDate", "+2y"); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - +2y"); + testHelper.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - +2y"); inl.datepicker("setDate", date1, date2); - datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - two dates"); + testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - two dates"); inl.datepicker("setDate"); ok(inl.datepicker("getDate") == null, "Set date inline - null"); // Alternate field @@ -581,23 +581,23 @@ test("setDate", function() { equal(inp.val(), "06/04/2008", "Set date alternate - 06/04/2008"); equal(alt.val(), "2008-06-04", "Set date alternate - 2008-06-04"); // With minimum/maximum - inp = datepickerTestHelpers.init("#inp"); + inp = testHelper.init("#inp"); date1 = new Date(2008, 1 - 1, 4); date2 = new Date(2008, 6 - 1, 4); minDate = new Date(2008, 2 - 1, 29); maxDate = new Date(2008, 3 - 1, 28); inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date2); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date2, "Set date min/max - setDate > min"); + testHelper.equalsDate(inp.datepicker("getDate"), date2, "Set date min/max - setDate > min"); inp.datepicker("setDate", date1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); + testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); inp.val("").datepicker("option", {maxDate: maxDate, minDate: null}).datepicker("setDate", date1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date min/max - setDate < max"); + testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date min/max - setDate < max"); inp.datepicker("setDate", date2); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); + testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date1); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); + testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); inp.datepicker("setDate", date2); - datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); + testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0); dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0); inp.datepicker("setDate", dateAndTimeToSet); @@ -606,7 +606,7 @@ test("setDate", function() { test("altField", function() { expect( 10 ); - var inp = datepickerTestHelpers.init("#inp"), + var inp = testHelper.init("#inp"), alt = $("#alt"); // No alternate field set alt.val(""); @@ -645,7 +645,7 @@ test("altField", function() { test("autoSize", function() { expect( 15 ); - var inp = datepickerTestHelpers.init("#inp"); + var inp = testHelper.init("#inp"); equal(inp.prop("size"), 20, "Auto size - default"); inp.datepicker("option", "autoSize", true); equal(inp.prop("size"), 10, "Auto size - mm/dd/yy"); @@ -683,7 +683,7 @@ test("autoSize", function() { test("daylightSaving", function() { expect( 25 ); - var inp = datepickerTestHelpers.init("#inp"), + var inp = testHelper.init("#inp"), dp = $("#ui-datepicker-div"); ok(true, "Daylight saving - " + new Date()); // Australia, Sydney - AM change, southern hemisphere @@ -789,7 +789,7 @@ test("callbacks", function() { expect( 13 ); // Before show var dp, day20, day21, - inp = datepickerTestHelpers.init("#inp", {beforeShow: beforeAll}), + inp = testHelper.init("#inp", {beforeShow: beforeAll}), inst = $.data(inp[0], "datepicker"); equal($.datepicker._get(inst, "currentText"), "Today", "Before show - initial"); inp.val("02/04/2008").datepicker("show"); @@ -799,7 +799,7 @@ test("callbacks", function() { deepEqual(beforeShowInst, inst, "Before show - inst OK"); inp.datepicker("hide").datepicker("destroy"); // Before show day - inp = datepickerTestHelpers.init("#inp", {beforeShowDay: beforeDay}); + inp = testHelper.init("#inp", {beforeShowDay: beforeDay}); dp = $("#ui-datepicker-div"); inp.val("02/04/2008").datepicker("show"); ok(beforeShowDayThis.id === inp[0].id, "Before show day - this OK"); @@ -818,7 +818,7 @@ test("callbacks", function() { test("beforeShowDay - tooltips with quotes", function() { expect( 1 ); var inp, dp; - inp = datepickerTestHelpers.init("#inp", { + inp = testHelper.init("#inp", { beforeShowDay: function() { return [ true, "", "'" ]; } @@ -833,7 +833,7 @@ test("beforeShowDay - tooltips with quotes", function() { test("localisation", function() { expect( 24 ); var dp, month, day, date, - inp = datepickerTestHelpers.init("#inp", $.datepicker.regional.fr); + inp = testHelper.init("#inp", $.datepicker.regional.fr); inp.datepicker("option", {dateFormat: "DD, d MM yy", showButtonPanel:true, changeMonth:true, changeYear:true}).val("").datepicker("show"); dp = $("#ui-datepicker-div"); equal($(".ui-datepicker-close", dp).text(), "Fermer", "Localisation - close"); @@ -900,72 +900,72 @@ test("iso8601Week", function() { test("parseDate", function() { expect( 26 ); - datepickerTestHelpers.init("#inp"); + testHelper.init("#inp"); var currentYear, gmtDate, fr, settings, zh; ok($.datepicker.parseDate("d m y", "") == null, "Parse date empty"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("d m y", "3 2 01"), + testHelper.equalsDate($.datepicker.parseDate("d m y", "3 2 01"), new Date(2001, 2 - 1, 3), "Parse date d m y"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("dd mm yy", "03 02 2001"), + testHelper.equalsDate($.datepicker.parseDate("dd mm yy", "03 02 2001"), new Date(2001, 2 - 1, 3), "Parse date dd mm yy"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("d m y", "13 12 01"), + testHelper.equalsDate($.datepicker.parseDate("d m y", "13 12 01"), new Date(2001, 12 - 1, 13), "Parse date d m y"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("dd mm yy", "13 12 2001"), + testHelper.equalsDate($.datepicker.parseDate("dd mm yy", "13 12 2001"), new Date(2001, 12 - 1, 13), "Parse date dd mm yy"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-o", "01-34"), + testHelper.equalsDate($.datepicker.parseDate("y-o", "01-34"), new Date(2001, 2 - 1, 3), "Parse date y-o"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("yy-oo", "2001-347"), + testHelper.equalsDate($.datepicker.parseDate("yy-oo", "2001-347"), new Date(2001, 12 - 1, 13), "Parse date yy-oo"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("oo yy", "348 2004"), + testHelper.equalsDate($.datepicker.parseDate("oo yy", "348 2004"), new Date(2004, 12 - 1, 13), "Parse date oo yy"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("D d M y", "Sat 3 Feb 01"), + testHelper.equalsDate($.datepicker.parseDate("D d M y", "Sat 3 Feb 01"), new Date(2001, 2 - 1, 3), "Parse date D d M y"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("d MM DD yy", "3 February Saturday 2001"), + testHelper.equalsDate($.datepicker.parseDate("d MM DD yy", "3 February Saturday 2001"), new Date(2001, 2 - 1, 3), "Parse date dd MM DD yy"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Saturday, February 3, 2001"), + testHelper.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Saturday, February 3, 2001"), new Date(2001, 2 - 1, 3), "Parse date DD, MM d, yy"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("'day' d 'of' MM (''DD''), yy", + testHelper.equalsDate($.datepicker.parseDate("'day' d 'of' MM (''DD''), yy", "day 3 of February ('Saturday'), 2001"), new Date(2001, 2 - 1, 3), "Parse date 'day' d 'of' MM (''DD''), yy"); currentYear = new Date().getFullYear(); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000) + "-02-03"), + testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000) + "-02-03"), new Date(currentYear, 2 - 1, 3), "Parse date y-m-d - default cutuff"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 10) + "-02-03"), + testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 10) + "-02-03"), new Date(currentYear+10, 2 - 1, 3), "Parse date y-m-d - default cutuff"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 11) + "-02-03"), + testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 11) + "-02-03"), new Date(currentYear-89, 2 - 1, 3), "Parse date y-m-d - default cutuff"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", "80-02-03", {shortYearCutoff: 80}), + testHelper.equalsDate($.datepicker.parseDate("y-m-d", "80-02-03", {shortYearCutoff: 80}), new Date(2080, 2 - 1, 3), "Parse date y-m-d - cutoff 80"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", "81-02-03", {shortYearCutoff: 80}), + testHelper.equalsDate($.datepicker.parseDate("y-m-d", "81-02-03", {shortYearCutoff: 80}), new Date(1981, 2 - 1, 3), "Parse date y-m-d - cutoff 80"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 60) + "-02-03", {shortYearCutoff: "+60"}), + testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 60) + "-02-03", {shortYearCutoff: "+60"}), new Date(currentYear + 60, 2 - 1, 3), "Parse date y-m-d - cutoff +60"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 61) + "-02-03", {shortYearCutoff: "+60"}), + testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 61) + "-02-03", {shortYearCutoff: "+60"}), new Date(currentYear - 39, 2 - 1, 3), "Parse date y-m-d - cutoff +60"); gmtDate = new Date(2001, 2 - 1, 3); gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("@", "981158400000"), gmtDate, "Parse date @"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("!", "631167552000000000"), gmtDate, "Parse date !"); + testHelper.equalsDate($.datepicker.parseDate("@", "981158400000"), gmtDate, "Parse date @"); + testHelper.equalsDate($.datepicker.parseDate("!", "631167552000000000"), gmtDate, "Parse date !"); fr = $.datepicker.regional.fr; settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; - datepickerTestHelpers.equalsDate($.datepicker.parseDate("D d M y", "Lun. 9 avr. 01", settings), + testHelper.equalsDate($.datepicker.parseDate("D d M y", "Lun. 9 avr. 01", settings), new Date(2001, 4 - 1, 9), "Parse date D M y with settings"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("d MM DD yy", "9 Avril Lundi 2001", settings), + testHelper.equalsDate($.datepicker.parseDate("d MM DD yy", "9 Avril Lundi 2001", settings), new Date(2001, 4 - 1, 9), "Parse date d MM DD yy with settings"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Lundi, Avril 9, 2001", settings), + testHelper.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Lundi, Avril 9, 2001", settings), new Date(2001, 4 - 1, 9), "Parse date DD, MM d, yy with settings"); - datepickerTestHelpers.equalsDate($.datepicker.parseDate("'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings), + testHelper.equalsDate($.datepicker.parseDate("'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings), new Date(2001, 4 - 1, 9), "Parse date 'jour' d 'de' MM (''DD''), yy with settings"); zh = $.datepicker.regional["zh-CN"]; - datepickerTestHelpers.equalsDate($.datepicker.parseDate("yy M d", "2011 十一月 22", zh), + testHelper.equalsDate($.datepicker.parseDate("yy M d", "2011 十一月 22", zh), new Date(2011, 11 - 1, 22), "Parse date yy M d with zh-CN"); }); test("parseDateErrors", function() { expect( 18 ); - datepickerTestHelpers.init("#inp"); + testHelper.init("#inp"); var fr, settings; function expectError(expr, value, error) { try { @@ -1040,7 +1040,7 @@ test("Ticket #7244: date parser does not fail when too many numbers are passed i test("formatDate", function() { expect( 16 ); - datepickerTestHelpers.init("#inp"); + testHelper.init("#inp"); var gmtDate, fr, settings; equal($.datepicker.formatDate("d m y", new Date(2001, 2 - 1, 3)), "3 2 01", "Format date d m y"); @@ -1093,7 +1093,7 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler var inp, dp; - inp = datepickerTestHelpers.init( "#inp", { + inp = testHelper.init( "#inp", { beforeShow: function() { } }); @@ -1102,7 +1102,7 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler equal( dp.css( "display" ), "block", "beforeShow returns nothing" ); inp.datepicker( "hide" ).datepicker( "destroy" ); - inp = datepickerTestHelpers.init( "#inp", { + inp = testHelper.init( "#inp", { beforeShow: function() { return true; } @@ -1113,7 +1113,7 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler inp.datepicker( "hide" ); inp.datepicker( "destroy" ); - inp = datepickerTestHelpers.init( "#inp", { + inp = testHelper.init( "#inp", { beforeShow: function() { return false; } diff --git a/tests/unit/datepicker/datepicker_test_helpers.js b/tests/unit/datepicker/datepicker_test_helpers.js index 40dc93410..4cd9b48ff 100644 --- a/tests/unit/datepicker/datepicker_test_helpers.js +++ b/tests/unit/datepicker/datepicker_test_helpers.js @@ -1,15 +1,17 @@ define( [ + "jquery", "lib/helper", "ui/datepicker" -], function( testHelpers ) { +], function( $, helper ) { -var datepickerTestHelpers = { +return $.extend( helper, { addMonths: function(date, offset) { var maxDay = 32 - new Date(date.getFullYear(), date.getMonth() + offset, 32).getDate(); date.setDate(Math.min(date.getDate(), maxDay)); date.setMonth(date.getMonth() + offset); return date; }, + equalsDate: function(d1, d2, message) { if (!d1 || !d2) { ok(false, message + " - missing date"); @@ -19,18 +21,18 @@ var datepickerTestHelpers = { d2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate()); equal(d1.toString(), d2.toString(), message); }, + init: function( id, options ) { $.datepicker.setDefaults( $.datepicker.regional[ "" ] ); return $( id ).datepicker( $.extend( { showAnim: "" }, options || {} ) ); }, + initNewInput: function( options ) { var id = $( "<input>" ).appendTo( "#qunit-fixture" ); - return datepickerTestHelpers.init( id, options ); + return this.init( id, options ); }, - onFocus: testHelpers.onFocus, - PROP_NAME: "datepicker" -}; -return datepickerTestHelpers; + PROP_NAME: "datepicker" +} ); } ); diff --git a/tests/unit/dialog/dialog_events.js b/tests/unit/dialog/dialog_events.js index a6e4c0501..cc5bef8fa 100644 --- a/tests/unit/dialog/dialog_events.js +++ b/tests/unit/dialog/dialog_events.js @@ -2,7 +2,7 @@ define( [ "jquery", "./dialog_test_helpers", "ui/dialog" -], function( $, dialogTestHelpers ) { +], function( $, testHelper ) { module("dialog: events"); @@ -104,7 +104,7 @@ test("dragStart", function() { }); handle = $(".ui-dialog-titlebar", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -132,7 +132,7 @@ test("drag", function() { }); handle = $(".ui-dialog-titlebar", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -156,7 +156,7 @@ test("dragStop", function() { }); handle = $(".ui-dialog-titlebar", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -184,7 +184,7 @@ test("resizeStart", function() { }); handle = $(".ui-resizable-se", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -216,7 +216,7 @@ test("resize", function() { }); handle = $(".ui-resizable-se", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); @@ -244,7 +244,7 @@ test("resizeStop", function() { }); handle = $(".ui-resizable-se", element.dialog("widget")); - dialogTestHelpers.drag(element, handle, 50, 50); + testHelper.drag(element, handle, 50, 50); element.remove(); }); diff --git a/tests/unit/dialog/dialog_options.js b/tests/unit/dialog/dialog_options.js index e4ff6ac72..1b9af7a09 100644 --- a/tests/unit/dialog/dialog_options.js +++ b/tests/unit/dialog/dialog_options.js @@ -4,7 +4,7 @@ define( [ "ui/dialog", "ui/effect-blind", "ui/effect-explode" -], function( $, dialogTestHelpers ) { +], function( $, testHelper ) { module("dialog: options"); @@ -231,15 +231,15 @@ test("draggable", function() { var element = $("<div></div>").dialog({ draggable: false }); - dialogTestHelpers.testDrag(element, 50, -50, 0, 0); + testHelper.testDrag(element, 50, -50, 0, 0); element.dialog("option", "draggable", true); - dialogTestHelpers.testDrag(element, 50, -50, 50, -50); + testHelper.testDrag(element, 50, -50, 50, -50); element.remove(); element = $("<div></div>").dialog({ draggable: true }); - dialogTestHelpers.testDrag(element, 50, -50, 50, -50); + testHelper.testDrag(element, 50, -50, 50, -50); element.dialog("option", "draggable", false); - dialogTestHelpers.testDrag(element, 50, -50, 0, 0); + testHelper.testDrag(element, 50, -50, 0, 0); element.remove(); }); @@ -269,17 +269,17 @@ test("maxHeight", function( assert ) { expect(3); var element = $("<div></div>").dialog({ maxHeight: 200 }); - dialogTestHelpers.drag(element, ".ui-resizable-s", 1000, 1000); + testHelper.drag(element, ".ui-resizable-s", 1000, 1000); assert.close(element.dialog("widget").height(), 200, 1, "maxHeight"); element.remove(); element = $("<div></div>").dialog({ maxHeight: 200 }); - dialogTestHelpers.drag(element, ".ui-resizable-n", -1000, -1000); + testHelper.drag(element, ".ui-resizable-n", -1000, -1000); assert.close(element.dialog("widget").height(), 200, 1, "maxHeight"); element.remove(); element = $("<div></div>").dialog({ maxHeight: 200 }).dialog("option", "maxHeight", 300); - dialogTestHelpers.drag(element, ".ui-resizable-s", 1000, 1000); + testHelper.drag(element, ".ui-resizable-s", 1000, 1000); assert.close(element.dialog("widget").height(), 300, 1, "maxHeight"); element.remove(); }); @@ -288,17 +288,17 @@ test("maxWidth", function( assert ) { expect(3); var element = $("<div></div>").dialog({ maxWidth: 200 }); - dialogTestHelpers.drag(element, ".ui-resizable-e", 1000, 1000); + testHelper.drag(element, ".ui-resizable-e", 1000, 1000); assert.close(element.dialog("widget").width(), 200, 1, "maxWidth"); element.remove(); element = $("<div></div>").dialog({ maxWidth: 200 }); - dialogTestHelpers.drag(element, ".ui-resizable-w", -1000, -1000); + testHelper.drag(element, ".ui-resizable-w", -1000, -1000); assert.close(element.dialog("widget").width(), 200, 1, "maxWidth"); element.remove(); element = $("<div></div>").dialog({ maxWidth: 200 }).dialog("option", "maxWidth", 300); - dialogTestHelpers.drag(element, ".ui-resizable-w", -1000, -1000); + testHelper.drag(element, ".ui-resizable-w", -1000, -1000); assert.close(element.dialog("widget").width(), 300, 1, "maxWidth"); element.remove(); }); @@ -307,17 +307,17 @@ test("minHeight", function( assert ) { expect(3); var element = $("<div></div>").dialog({ minHeight: 10 }); - dialogTestHelpers.drag(element, ".ui-resizable-s", -1000, -1000); + testHelper.drag(element, ".ui-resizable-s", -1000, -1000); assert.close(element.dialog("widget").height(), 10, 1, "minHeight"); element.remove(); element = $("<div></div>").dialog({ minHeight: 10 }); - dialogTestHelpers.drag(element, ".ui-resizable-n", 1000, 1000); + testHelper.drag(element, ".ui-resizable-n", 1000, 1000); assert.close(element.dialog("widget").height(), 10, 1, "minHeight"); element.remove(); element = $("<div></div>").dialog({ minHeight: 10 }).dialog("option", "minHeight", 30); - dialogTestHelpers.drag(element, ".ui-resizable-n", 1000, 1000); + testHelper.drag(element, ".ui-resizable-n", 1000, 1000); assert.close(element.dialog("widget").height(), 30, 1, "minHeight"); element.remove(); }); @@ -326,17 +326,17 @@ test("minWidth", function( assert ) { expect(3); var element = $("<div></div>").dialog({ minWidth: 10 }); - dialogTestHelpers.drag(element, ".ui-resizable-e", -1000, -1000); + testHelper.drag(element, ".ui-resizable-e", -1000, -1000); assert.close(element.dialog("widget").width(), 10, 1, "minWidth"); element.remove(); element = $("<div></div>").dialog({ minWidth: 10 }); - dialogTestHelpers.drag(element, ".ui-resizable-w", 1000, 1000); + testHelper.drag(element, ".ui-resizable-w", 1000, 1000); assert.close(element.dialog("widget").width(), 10, 1, "minWidth"); element.remove(); element = $("<div></div>").dialog({ minWidth: 30 }).dialog("option", "minWidth", 30); - dialogTestHelpers.drag(element, ".ui-resizable-w", 1000, 1000); + testHelper.drag(element, ".ui-resizable-w", 1000, 1000); assert.close(element.dialog("widget").width(), 30, 1, "minWidth"); element.remove(); }); @@ -424,15 +424,15 @@ test("resizable", function() { expect(4); var element = $("<div></div>").dialog(); - dialogTestHelpers.shouldResize(element, 50, 50, "[default]"); + testHelper.shouldResize(element, 50, 50, "[default]"); element.dialog("option", "resizable", false); - dialogTestHelpers.shouldResize(element, 0, 0, "disabled after init"); + testHelper.shouldResize(element, 0, 0, "disabled after init"); element.remove(); element = $("<div></div>").dialog({ resizable: false }); - dialogTestHelpers.shouldResize(element, 0, 0, "disabled in init options"); + testHelper.shouldResize(element, 0, 0, "disabled in init options"); element.dialog("option", "resizable", true); - dialogTestHelpers.shouldResize(element, 50, 50, "enabled after init"); + testHelper.shouldResize(element, 50, 50, "enabled after init"); element.remove(); }); @@ -497,18 +497,18 @@ test("#4826: setting resizable false toggles resizable on dialog", function() { var i, element = $("<div></div>").dialog({ resizable: false }); - dialogTestHelpers.shouldResize(element, 0, 0, "[default]"); + testHelper.shouldResize(element, 0, 0, "[default]"); for (i=0; i<2; i++) { element.dialog("close").dialog("open"); - dialogTestHelpers.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")"); + testHelper.shouldResize(element, 0, 0, "initialized with resizable false toggle ("+ (i+1) +")"); } element.remove(); element = $("<div></div>").dialog({ resizable: true }); - dialogTestHelpers.shouldResize(element, 50, 50, "[default]"); + testHelper.shouldResize(element, 50, 50, "[default]"); for (i=0; i<2; i++) { element.dialog("close").dialog("option", "resizable", false).dialog("open"); - dialogTestHelpers.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")"); + testHelper.shouldResize(element, 0, 0, "set option resizable false toggle ("+ (i+1) +")"); } element.remove(); diff --git a/tests/unit/dialog/dialog_test_helpers.js b/tests/unit/dialog/dialog_test_helpers.js index f11c77cde..f84d1d624 100644 --- a/tests/unit/dialog/dialog_test_helpers.js +++ b/tests/unit/dialog/dialog_test_helpers.js @@ -1,6 +1,10 @@ -define( function() { +define( [ + "jquery", + "lib/helper", + "ui/dialog" +], function( $, helper ) { -var dialogTestHelpers = { +return $.extend( helper, { drag: function(element, handle, dx, dy) { var d = element.dialog("widget"); //this mouseover is to work around a limitation in resizable @@ -16,7 +20,7 @@ var dialogTestHelpers = { handle = $(".ui-dialog-titlebar", d), offsetBefore = d.offset(); - dialogTestHelpers.drag(element, handle, dx, dy); + this.drag(element, handle, dx, dy); offsetAfter = d.offset(); @@ -36,7 +40,7 @@ var dialogTestHelpers = { heightBefore = element.height(), widthBefore = element.width(); - dialogTestHelpers.drag(element, handle, 50, 50); + this.drag(element, handle, 50, 50); heightAfter = element.height(); widthAfter = element.width(); @@ -46,8 +50,6 @@ var dialogTestHelpers = { expected = { width: widthBefore + dw, height: heightBefore + dh }; deepEqual(actual, expected, "resized[" + 50 + ", " + 50 + "] " + msg); } -}; - -return dialogTestHelpers; +} ); } ); diff --git a/tests/unit/draggable/draggable_core.js b/tests/unit/draggable/draggable_core.js index 30d75b880..6f6dc1a14 100644 --- a/tests/unit/draggable/draggable_core.js +++ b/tests/unit/draggable/draggable_core.js @@ -1,11 +1,10 @@ define( [ "jquery", - "lib/helper", "./draggable_test_helpers", "ui/draggable", "ui/droppable", "ui/resizable" -], function( $, testHelpers, draggableTestHelpers ) { +], function( $, testHelper ) { module( "draggable: core" ); @@ -47,12 +46,12 @@ test( "element types", function( assert ) { test( "No options, relative", function() { expect( 2 ); - draggableTestHelpers.shouldMove( $( "#draggable1" ).draggable(), "no options, relative" ); + testHelper.shouldMove( $( "#draggable1" ).draggable(), "no options, relative" ); }); test( "No options, absolute", function() { expect( 2 ); - draggableTestHelpers.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" ); + testHelper.shouldMove( $( "#draggable2" ).draggable(), "no options, absolute" ); }); test( "resizable handle with complex markup (#8756 / #8757)", function() { @@ -95,7 +94,7 @@ test( "#8269: Removing draggable element on drop", function() { }); // Support: Opera 12.10, Safari 5.1, jQuery <1.8 - if ( draggableTestHelpers.unreliableContains ) { + if ( testHelper.unreliableContains ) { ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); } else { @@ -121,7 +120,7 @@ test( "Stray mousemove after mousedown still drags", function() { $( document ).simulate( "mousemove", { button: -1 }); }); - draggableTestHelpers.shouldMove( element, "element is draggable" ); + testHelper.shouldMove( element, "element is draggable" ); }); test( "#6258: not following mouse when scrolled and using overflow-y: scroll", function() { @@ -141,7 +140,7 @@ test( "#6258: not following mouse when scrolled and using overflow-y: scroll", f oldOverflowY = $( "html" ).css( "overflow-y" ), oldOverflowX = $( "html" ).css( "overflow-x" ); - testHelpers.forceScrollableWindow(); + testHelper.forceScrollableWindow(); $( "html" ) .css( "overflow-y", "scroll" ) @@ -167,7 +166,7 @@ test( "#9315: jumps down with offset of scrollbar", function() { } }); - testHelpers.forceScrollableWindow(); + testHelper.forceScrollableWindow(); $( "html" ).scrollTop( 300 ).scrollLeft( 300 ); @@ -201,7 +200,7 @@ test( "scroll offset with fixed ancestors", function() { } }); - testHelpers.forceScrollableWindow(); + testHelper.forceScrollableWindow(); $( "#wrapper" ).css( "position", "fixed" ); $( "#wrapper2" ).css( "position", "absolute" ); @@ -272,8 +271,8 @@ test( "#5727: draggable from iframe", function() { equal( draggable1.closest( iframeBody ).length, 1 ); // TODO: fix draggable within an IFRAME to fire events on the element properly - // and these draggableTestHelpers.shouldMove relies on events for testing - //draggableTestHelpers.shouldMove( draggable1, "draggable from an iframe" ); + // and these testHelper.shouldMove relies on events for testing + //testHelper.shouldMove( draggable1, "draggable from an iframe" ); }); test( "#8399: A draggable should become the active element after you are finished interacting with it, but not before.", function() { @@ -285,7 +284,7 @@ test( "#8399: A draggable should become the active element after you are finishe notStrictEqual( document.activeElement, element.get( 0 ), "moving a draggable anchor did not make it the active element" ); }); - draggableTestHelpers.move( element, 50, 50 ); + testHelper.move( element, 50, 50 ); strictEqual( document.activeElement, element.get( 0 ), "finishing moving a draggable anchor made it the active element" ); }); @@ -296,16 +295,16 @@ asyncTest( "blur behavior", function() { var element = $( "#draggable1" ).draggable(), focusElement = $( "<div tabindex='1'></div>" ).appendTo( element ); - testHelpers.onFocus( focusElement, function() { + testHelper.onFocus( focusElement, function() { strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused before mousing down on a draggable" ); - draggableTestHelpers.move( focusElement, 1, 1 ); + testHelper.move( focusElement, 1, 1 ); // http://bugs.jqueryui.com/ticket/10527 // Draggable: Can't select option in modal dialog (IE8) strictEqual( document.activeElement, focusElement.get( 0 ), "test element is focused after mousing down on itself" ); - draggableTestHelpers.move( element, 50, 50 ); + testHelper.move( element, 50, 50 ); // http://bugs.jqueryui.com/ticket/4261 // active element should blur when mousing down on a draggable diff --git a/tests/unit/draggable/draggable_methods.js b/tests/unit/draggable/draggable_methods.js index 44e5feb43..74c5b67e8 100644 --- a/tests/unit/draggable/draggable_methods.js +++ b/tests/unit/draggable/draggable_methods.js @@ -2,7 +2,7 @@ define( [ "jquery", "./draggable_test_helpers", "ui/draggable" -], function( $, draggableTestHelpers ) { +], function( $, testHelper ) { var element; @@ -55,19 +55,19 @@ test( "enable", function() { expect( 11 ); element.draggable({ disabled: true }); - draggableTestHelpers.shouldNotDrag( element, ".draggable({ disabled: true })" ); + testHelper.shouldNotDrag( element, ".draggable({ disabled: true })" ); element.draggable("enable"); - draggableTestHelpers.shouldMove( element, ".draggable('enable')" ); + testHelper.shouldMove( element, ".draggable('enable')" ); equal( element.draggable( "option", "disabled" ), false, "disabled option getter" ); element.draggable("destroy"); element.draggable({ disabled: true }); - draggableTestHelpers.shouldNotDrag( element, ".draggable({ disabled: true })" ); + testHelper.shouldNotDrag( element, ".draggable({ disabled: true })" ); element.draggable( "option", "disabled", false ); equal(element.draggable( "option", "disabled" ), false, "disabled option setter" ); - draggableTestHelpers.shouldMove( element, ".draggable('option', 'disabled', false)" ); + testHelper.shouldMove( element, ".draggable('option', 'disabled', false)" ); var expected = element.draggable(), actual = expected.draggable("enable"); @@ -78,19 +78,19 @@ test( "disable", function( assert ) { expect( 14 ); element = $( "#draggable2" ).draggable({ disabled: false }); - draggableTestHelpers.shouldMove( element, ".draggable({ disabled: false })" ); + testHelper.shouldMove( element, ".draggable({ disabled: false })" ); element.draggable( "disable" ); - draggableTestHelpers.shouldNotDrag( element, ".draggable('disable')" ); + testHelper.shouldNotDrag( element, ".draggable('disable')" ); equal( element.draggable( "option", "disabled" ), true, "disabled option getter" ); element.draggable( "destroy" ); element.draggable({ disabled: false }); - draggableTestHelpers.shouldMove( element, ".draggable({ disabled: false })" ); + testHelper.shouldMove( element, ".draggable({ disabled: false })" ); element.draggable( "option", "disabled", true ); equal( element.draggable( "option", "disabled" ), true, "disabled option setter" ); - draggableTestHelpers.shouldNotDrag( element, ".draggable('option', 'disabled', true)" ); + testHelper.shouldNotDrag( element, ".draggable('option', 'disabled', true)" ); assert.lacksClasses( element.draggable( "widget" ), "ui-state-disabled" ); ok( !element.draggable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); diff --git a/tests/unit/draggable/draggable_options.js b/tests/unit/draggable/draggable_options.js index a67854e96..5368103b7 100644 --- a/tests/unit/draggable/draggable_options.js +++ b/tests/unit/draggable/draggable_options.js @@ -4,16 +4,16 @@ define( [ "ui/draggable", "ui/droppable", "ui/sortable" -], function( $, draggableTestHelpers ) { +], function( $, testHelper ) { // TODO: This doesn't actually test whether append happened, possibly remove test( "{ appendTo: 'parent' }, default, no clone", function() { expect( 4 ); var element = $( "#draggable2" ).draggable({ appendTo: "parent" }); - draggableTestHelpers.shouldMove( element, "absolute appendTo: parent" ); + testHelper.shouldMove( element, "absolute appendTo: parent" ); element = $( "#draggable1" ).draggable({ appendTo: "parent" }); - draggableTestHelpers.shouldMove( element, "relative appendTo: parent" ); + testHelper.shouldMove( element, "relative appendTo: parent" ); }); // TODO: This doesn't actually test whether append happened, possibly remove @@ -21,20 +21,20 @@ test( "{ appendTo: Element }, no clone", function() { expect( 4 ); var element = $( "#draggable2" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] }); - draggableTestHelpers.shouldMove( element, "absolute appendTo: Element" ); + testHelper.shouldMove( element, "absolute appendTo: Element" ); element = $( "#draggable1" ).draggable({ appendTo: $( "#draggable2" ).parent()[ 0 ] }); - draggableTestHelpers.shouldMove( element, "relative appendTo: Element" ); + testHelper.shouldMove( element, "relative appendTo: Element" ); }); // TODO: This doesn't actually test whether append happened, possibly remove test( "{ appendTo: Selector }, no clone", function() { expect( 4 ); var element = $( "#draggable2" ).draggable({ appendTo: "#main" }); - draggableTestHelpers.shouldMove( element, "absolute appendTo: Selector" ); + testHelper.shouldMove( element, "absolute appendTo: Selector" ); element = $( "#draggable1" ).draggable({ appendTo: "#main" }); - draggableTestHelpers.shouldMove( element, "relative appendTo: Selector" ); + testHelper.shouldMove( element, "relative appendTo: Selector" ); }); test( "{ appendTo: 'parent' }, default", function() { @@ -42,11 +42,11 @@ test( "{ appendTo: 'parent' }, default", function() { var element = $( "#draggable1" ).draggable(); - draggableTestHelpers.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); equal( element.draggable( "option", "appendTo" ), "parent" ); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] ); }); @@ -56,9 +56,9 @@ test( "{ appendTo: Element }", function() { var appendTo = $( "#draggable2" ).parent()[ 0 ], element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - draggableTestHelpers.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), appendTo ); }); @@ -68,9 +68,9 @@ test( "{ appendTo: jQuery }", function() { var appendTo = $( "#draggable2" ).parent(), element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - draggableTestHelpers.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), appendTo[ 0 ] ); }); @@ -80,9 +80,9 @@ test( "{ appendTo: Selector }", function() { var appendTo = "#main", element = $( "#draggable1" ).draggable({ appendTo: appendTo }); - draggableTestHelpers.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), $(appendTo)[ 0 ] ); }); @@ -91,34 +91,34 @@ test( "appendTo, default, switching after initialization", function() { var element = $( "#draggable1" ).draggable({ helper: "clone" }); - draggableTestHelpers.trackAppendedParent( element ); + testHelper.trackAppendedParent( element ); // Move and make sure element was appended to fixture - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_parent" ), $( "#main" )[ 0 ] ); // Move and make sure element was appended to main element.draggable( "option", "appendTo", $( "#qunit-fixture" ) ); - draggableTestHelpers.move( element, 2, 2 ); + testHelper.move( element, 2, 2 ); equal( element.data( "last_dragged_parent" ), $( "#qunit-fixture" )[ 0 ] ); }); test( "{ axis: false }, default", function() { expect( 2 ); var element = $( "#draggable2" ).draggable({ axis: false }); - draggableTestHelpers.shouldMove( element, "axis: false" ); + testHelper.shouldMove( element, "axis: false" ); }); test( "{ axis: 'x' }", function() { expect( 2 ); var element = $( "#draggable2" ).draggable({ axis: "x" }); - draggableTestHelpers.testDrag( element, element, 50, 50, 50, 0, "axis: x" ); + testHelper.testDrag( element, element, 50, 50, 50, 0, "axis: x" ); }); test( "{ axis: 'y' }", function() { expect( 2 ); var element = $( "#draggable2" ).draggable({ axis: "y" }); - draggableTestHelpers.testDrag( element, element, 50, 50, 0, 50, "axis: y" ); + testHelper.testDrag( element, element, 50, 50, 0, 50, "axis: y" ); }); test( "{ axis: ? }, unexpected", function() { @@ -136,7 +136,7 @@ test( "{ axis: ? }, unexpected", function() { $.each(unexpected, function(key, val) { element = $( "#draggable2" ).draggable({ axis: val }); - draggableTestHelpers.shouldMove( element, "axis: " + key ); + testHelper.shouldMove( element, "axis: " + key ); element.draggable( "destroy" ); }); }); @@ -147,15 +147,15 @@ test( "axis, default, switching after initialization", function() { var element = $( "#draggable1" ).draggable({ axis: false }); // Any Direction - draggableTestHelpers.shouldMove( element, "axis: default" ); + testHelper.shouldMove( element, "axis: default" ); // Only horizontal element.draggable( "option", "axis", "x" ); - draggableTestHelpers.testDrag( element, element, 50, 50, 50, 0, "axis: x as option" ); + testHelper.testDrag( element, element, 50, 50, 50, 0, "axis: x as option" ); // Vertical only element.draggable( "option", "axis", "y" ); - draggableTestHelpers.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" ); + testHelper.testDrag( element, element, 50, 50, 0, 50, "axis: y as option" ); }); @@ -165,12 +165,12 @@ test( "{ cancel: 'input,textarea,button,select,option' }, default", function() { $( "<div id='draggable-option-cancel-default'><input type='text'></div>" ).appendTo( "#qunit-fixture" ); var element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); - draggableTestHelpers.shouldMove( element, "cancel: default, element dragged" ); + testHelper.shouldMove( element, "cancel: default, element dragged" ); element.draggable( "destroy" ); element = $( "#draggable-option-cancel-default" ).draggable({ cancel: "input,textarea,button,select,option" }); - draggableTestHelpers.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" ); + testHelper.shouldNotDrag( element, "cancel: default, input dragged", "#draggable-option-cancel-default input" ); element.draggable( "destroy" ); }); @@ -178,12 +178,12 @@ test( "{ cancel: 'span' }", function() { expect( 4 ); var element = $( "#draggable2" ).draggable(); - draggableTestHelpers.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" ); + testHelper.shouldMove( element, "cancel: default, span dragged", "#draggable2 span" ); element.draggable( "destroy" ); element = $( "#draggable2" ).draggable({ cancel: "span" }); - draggableTestHelpers.shouldNotDrag( element, "cancel: span, span dragged", "#draggable2 span" ); + testHelper.shouldNotDrag( element, "cancel: span, span dragged", "#draggable2 span" ); }); test( "{ cancel: ? }, unexpected", function() { @@ -201,7 +201,7 @@ test( "{ cancel: ? }, unexpected", function() { $.each( unexpected, function( key, val ) { element = $( "#draggable2" ).draggable({ cancel: val }); - draggableTestHelpers.shouldMove( element, "cancel: " + key ); + testHelper.shouldMove( element, "cancel: " + key ); element.draggable( "destroy" ); }); }); @@ -219,15 +219,15 @@ test( "{ cancel: Selectors }, matching parent selector", function() { $( "#wrapping a" ).append( element ); - draggableTestHelpers.shouldMove( element, "drag span child", "#draggable2 span" ); - draggableTestHelpers.shouldNotDrag( $( "#draggable2 span a" ), "drag span a" ); - draggableTestHelpers.shouldNotDrag( $( "#wrapping a" ), "drag wrapping a" ); + testHelper.shouldMove( element, "drag span child", "#draggable2 span" ); + testHelper.shouldNotDrag( $( "#draggable2 span a" ), "drag span a" ); + testHelper.shouldNotDrag( $( "#wrapping a" ), "drag wrapping a" ); $( "#draggable2" ).draggable( "option", "cancel", "span > a" ); $( "#draggable2" ).find( "a" ).append( "<a>" ); - draggableTestHelpers.shouldMove( element, "drag span child", $( "#draggable2 span a" ).last() ); - draggableTestHelpers.shouldNotDrag( $( "#draggable2 span a" ).first(), "drag span a first child" ); + testHelper.shouldMove( element, "drag span child", $( "#draggable2 span a" ).last() ); + testHelper.shouldNotDrag( $( "#draggable2 span a" ).first(), "drag span a first child" ); }); */ @@ -239,13 +239,13 @@ test( "cancelement, default, switching after initialization", function() { var input = $( "#draggable-option-cancel-default input" ), element = $( "#draggable-option-cancel-default" ).draggable(); - draggableTestHelpers.shouldNotDrag( element, "cancel: default, input dragged", input ); + testHelper.shouldNotDrag( element, "cancel: default, input dragged", input ); element.draggable( "option", "cancel", "textarea" ); - draggableTestHelpers.shouldMove( element, "cancel: textarea, input dragged", input ); + testHelper.shouldMove( element, "cancel: textarea, input dragged", input ); element.draggable( "option", "cancel", "input" ); - draggableTestHelpers.shouldNotDrag( element, "cancel: input, input dragged", input ); + testHelper.shouldNotDrag( element, "cancel: input, input dragged", input ); }); test( "connectToSortable, dragging out of a sortable", function() { @@ -440,8 +440,8 @@ test( "{ containment: Element }", function() { p = element.parent(), po = p.offset(), expected = { - left: po.left + draggableTestHelpers.border( p, "left" ) + draggableTestHelpers.margin( element, "left" ), - top: po.top + draggableTestHelpers.border( p, "top" ) + draggableTestHelpers.margin( element, "top" ) + left: po.left + testHelper.border( p, "left" ) + testHelper.margin( element, "left" ), + top: po.top + testHelper.border( p, "top" ) + testHelper.margin( element, "top" ) }; element.simulate( "drag", { @@ -460,8 +460,8 @@ test( "{ containment: Selector }", function() { p = element.parent(), po = p.offset(), expected = { - left: po.left + draggableTestHelpers.border( p, "left" ) + draggableTestHelpers.margin( element, "left" ), - top: po.top + draggableTestHelpers.border( p, "top" ) + draggableTestHelpers.margin( element, "top" ) + left: po.left + testHelper.border( p, "left" ) + testHelper.margin( element, "left" ), + top: po.top + testHelper.border( p, "top" ) + testHelper.margin( element, "top" ) }; element.simulate( "drag", { @@ -480,7 +480,7 @@ test( "{ containment: [x1, y1, x2, y2] }", function() { element.draggable( "option", "containment", [ eo.left, eo.top, eo.left + element.width() + 5, eo.top + element.height() + 5 ] ); - draggableTestHelpers.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" ); + testHelper.testDrag( element, element, -100, -100, 0, 0, "containment: [x1, y1, x2, y2]" ); }); test( "{ containment: 'parent' }, relative", function() { @@ -491,8 +491,8 @@ test( "{ containment: 'parent' }, relative", function() { p = element.parent(), po = p.offset(), expected = { - left: po.left + draggableTestHelpers.border( p, "left" ) + draggableTestHelpers.margin( element, "left" ), - top: po.top + draggableTestHelpers.border( p, "top" ) + draggableTestHelpers.margin( element, "top" ) + left: po.left + testHelper.border( p, "left" ) + testHelper.margin( element, "left" ), + top: po.top + testHelper.border( p, "top" ) + testHelper.margin( element, "top" ) }; element.simulate( "drag", { @@ -511,8 +511,8 @@ test( "{ containment: 'parent' }, absolute", function() { p = element.parent(), po = p.offset(), expected = { - left: po.left + draggableTestHelpers.border( p, "left" ) + draggableTestHelpers.margin( element, "left" ), - top: po.top + draggableTestHelpers.border( p, "top" ) + draggableTestHelpers.margin( element, "top" ) + left: po.left + testHelper.border( p, "left" ) + testHelper.margin( element, "left" ), + top: po.top + testHelper.border( p, "top" ) + testHelper.margin( element, "top" ) }; element.simulate( "drag", { @@ -535,8 +535,8 @@ test( "containment, account for border", function( assert ) { }), parentBottom = parent.offset().top + parent.outerHeight(), parentRight = parent.offset().left + parent.outerWidth(), - parentBorderBottom = draggableTestHelpers.border( parent, "bottom" ), - parentBorderRight = draggableTestHelpers.border( parent, "right" ); + parentBorderBottom = testHelper.border( parent, "bottom" ), + parentBorderRight = testHelper.border( parent, "right" ); el.css({ height: "5px", @@ -591,16 +591,16 @@ test( "containment, default, switching after initialization", function() { po = element.parent().offset(), containment = [ po.left - 100, po.top - 100, po.left + 500, po.top + 500 ]; - draggableTestHelpers.testDrag( element, element, -100, -100, -100, -100, "containment: default" ); + testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: default" ); element.draggable( "option", "containment", "parent" ).css({ top: 0, left: 0 }); - draggableTestHelpers.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" ); + testHelper.testDrag( element, element, -100, -100, 0, 0, "containment: parent as option" ); element.draggable( "option", "containment", containment ).css({ top: 0, left: 0 }); - draggableTestHelpers.testDrag( element, element, -100, -100, -100, -100, "containment: array as option" ); + testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: array as option" ); element.draggable( "option", "containment", false ); - draggableTestHelpers.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" ); + testHelper.testDrag( element, element, -100, -100, -100, -100, "containment: false as option" ); }); test( "{ cursor: 'auto' }, default", function() { @@ -678,7 +678,7 @@ test( "#6889: Cursor doesn't revert to pre-dragging state after revert action wh }), expected = getCursor(); - if ( draggableTestHelpers.unreliableContains ) { + if ( testHelper.unreliableContains ) { ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); } else { @@ -694,17 +694,17 @@ test( "cursor, default, switching after initialization", function() { var element = $( "#draggable1" ).draggable(); - draggableTestHelpers.trackMouseCss( element ); + testHelper.trackMouseCss( element ); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_cursor" ), "auto" ); element.draggable( "option", "cursor", "move" ); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_cursor" ), "move" ); element.draggable( "option", "cursor", "ns-resize" ); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.data( "last_dragged_cursor" ), "ns-resize" ); }); @@ -731,11 +731,11 @@ test( "cursorAt", function() { equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" ); } else if ( testData.cursorAt.right ) { - equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - draggableTestHelpers.unreliableOffset, testName + " " + position + " left" ); - equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - draggableTestHelpers.unreliableOffset, testName + " " + position + " top" ); + equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" ); + equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" ); } else { - equal( event.clientX - ui.offset.left, testData.x + draggableTestHelpers.unreliableOffset, testName + " " + position + " left" ); - equal( event.clientY - ui.offset.top, testData.y + draggableTestHelpers.unreliableOffset, testName + " " + position + " top" ); + equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" ); + equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" ); } } }); @@ -773,11 +773,11 @@ test( "cursorAt, switching after initialization", function() { equal( ui.position.left - ui.originalPosition.left, deltaX, testName + " " + position + " left" ); equal( ui.position.top - ui.originalPosition.top, deltaY, testName + " " + position + " top" ); } else if ( testData.cursorAt.right ) { - equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - draggableTestHelpers.unreliableOffset, testName + " " + position + " left" ); - equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - draggableTestHelpers.unreliableOffset, testName + " " + position + " top" ); + equal( ui.helper.width() - ( event.clientX - ui.offset.left ), testData.x - testHelper.unreliableOffset, testName + " " + position + " left" ); + equal( ui.helper.height() - ( event.clientY - ui.offset.top ), testData.y - testHelper.unreliableOffset, testName + " " + position + " top" ); } else { - equal( event.clientX - ui.offset.left, testData.x + draggableTestHelpers.unreliableOffset, testName + " " + position + " left" ); - equal( event.clientY - ui.offset.top, testData.y + draggableTestHelpers.unreliableOffset, testName + " " + position + " top" ); + equal( event.clientX - ui.offset.left, testData.x + testHelper.unreliableOffset, testName + " " + position + " left" ); + equal( event.clientY - ui.offset.top, testData.y + testHelper.unreliableOffset, testName + " " + position + " top" ); } } }); @@ -799,29 +799,29 @@ test( "disabled", function() { var element = $( "#draggable1" ).draggable(); - draggableTestHelpers.shouldMove( element, "disabled: default" ); + testHelper.shouldMove( element, "disabled: default" ); element.draggable( "option", "disabled", true ); - draggableTestHelpers.shouldNotDrag( element, "option: disabled true" ); + testHelper.shouldNotDrag( element, "option: disabled true" ); element.draggable( "option", "disabled", false ); - draggableTestHelpers.shouldMove( element, "option: disabled false" ); + testHelper.shouldMove( element, "option: disabled false" ); }); test( "{ grid: [50, 50] }, relative", function() { expect( 4 ); var element = $( "#draggable1" ).draggable({ grid: [ 50, 50 ] }); - draggableTestHelpers.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" ); - draggableTestHelpers.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" ); + testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] relative" ); + testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] relative" ); }); test( "{ grid: [50, 50] }, absolute", function() { expect( 4 ); var element = $( "#draggable2" ).draggable({ grid: [ 50, 50 ] }); - draggableTestHelpers.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" ); - draggableTestHelpers.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" ); + testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] absolute" ); + testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] absolute" ); }); test( "grid, switching after initialization", function() { @@ -830,13 +830,13 @@ test( "grid, switching after initialization", function() { var element = $( "#draggable1" ).draggable(); // Forward - draggableTestHelpers.testDrag( element, element, 24, 24, 24, 24, "grid: default" ); - draggableTestHelpers.testDrag( element, element, 0, 0, 0, 0, "grid: default" ); + testHelper.testDrag( element, element, 24, 24, 24, 24, "grid: default" ); + testHelper.testDrag( element, element, 0, 0, 0, 0, "grid: default" ); element.draggable( "option", "grid", [ 50, 50 ] ); - draggableTestHelpers.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" ); - draggableTestHelpers.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" ); + testHelper.testDrag( element, element, 24, 24, 0, 0, "grid: [50, 50] as option" ); + testHelper.testDrag( element, element, 26, 25, 50, 50, "grid: [50, 50] as option" ); }); test( "{ handle: 'span' }", function() { @@ -844,9 +844,9 @@ test( "{ handle: 'span' }", function() { var element = $( "#draggable2" ).draggable({ handle: "span" }); - draggableTestHelpers.shouldMove( element, "handle: span", "#draggable2 span"); - draggableTestHelpers.shouldMove( element, "handle: span child", "#draggable2 span em" ); - draggableTestHelpers.shouldNotDrag( element, "handle: span element" ); + testHelper.shouldMove( element, "handle: span", "#draggable2 span"); + testHelper.shouldMove( element, "handle: span child", "#draggable2 span em" ); + testHelper.shouldNotDrag( element, "handle: span element" ); }); test( "handle, default, switching after initialization", function() { @@ -854,31 +854,31 @@ test( "handle, default, switching after initialization", function() { var element = $( "#draggable2" ).draggable(); - draggableTestHelpers.shouldMove( element, "handle: default, element dragged" ); - draggableTestHelpers.shouldMove( element, "handle: default, span dragged", "#draggable2 span" ); + testHelper.shouldMove( element, "handle: default, element dragged" ); + testHelper.shouldMove( element, "handle: default, span dragged", "#draggable2 span" ); // Switch element.draggable( "option", "handle", "span" ); - draggableTestHelpers.shouldNotDrag( element, "handle: span as option, element dragged" ); - draggableTestHelpers.shouldMove( element, "handle: span as option, span dragged", "#draggable2 span" ); + testHelper.shouldNotDrag( element, "handle: span as option, element dragged" ); + testHelper.shouldMove( element, "handle: span as option, span dragged", "#draggable2 span" ); // And back element.draggable( "option", "handle", false ); - draggableTestHelpers.shouldMove( element, "handle: false as option, element dragged" ); - draggableTestHelpers.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" ); + testHelper.shouldMove( element, "handle: false as option, element dragged" ); + testHelper.shouldMove( element, "handle: false as option, span dragged", "#draggable2 span" ); }); test( "helper, default, switching after initialization", function() { expect( 6 ); var element = $( "#draggable1" ).draggable(); - draggableTestHelpers.shouldMove( element, "helper: default" ); + testHelper.shouldMove( element, "helper: default" ); element.draggable( "option", "helper", "clone" ); - draggableTestHelpers.shouldMove( element, "helper: clone" ); + testHelper.shouldMove( element, "helper: clone" ); element.draggable( "option", "helper", "original" ); - draggableTestHelpers.shouldMove( element, "helper: original" ); + testHelper.shouldMove( element, "helper: original" ); }); // http://bugs.jqueryui.com/ticket/9446 @@ -892,7 +892,7 @@ test( "helper, function returning original element", function() { } }); - draggableTestHelpers.testDragHelperOffset( element, 100, 100, 100, 100, "original element is draggable" ); + testHelper.testDragHelperOffset( element, 100, 100, 100, 100, "original element is draggable" ); element.simulate( "drag", { dx: 100, @@ -911,25 +911,25 @@ function testHelperPosition( scrollPositions, position, helper, scrollElements, }); if ( scrollElements.length === 1 && scrollElements[ 0 ] === "#scrollParent" ) { - draggableTestHelpers.setScrollable( "#main", false ); - draggableTestHelpers.setScrollable( "#scrollParent", true ); + testHelper.setScrollable( "#main", false ); + testHelper.setScrollable( "#scrollParent", true ); } for ( j = 0; j < scrollPositions.length; j++ ) { for ( i = 0; i < scrollElements.length; i++ ) { - draggableTestHelpers.setScroll( scrollElements[ i ] ); + testHelper.setScroll( scrollElements[ i ] ); } - draggableTestHelpers.testScroll( element, scrollPositions[ j ] ); + testHelper.testScroll( element, scrollPositions[ j ] ); for ( i = 0; i < scrollElements.length; i++ ) { - draggableTestHelpers.restoreScroll( scrollElements[ i ] ); + testHelper.restoreScroll( scrollElements[ i ] ); } } if ( scrollElements.length === 1 && scrollElements[ 1 ] === "#scrollParent" ) { - draggableTestHelpers.setScrollable( "#main", true ); - draggableTestHelpers.setScrollable( "#scrollParent", false ); + testHelper.setScrollable( "#main", true ); + testHelper.setScrollable( "#scrollParent", false ); } }); } @@ -987,15 +987,15 @@ test( "opacity, default, switching after initialization", function() { } }); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( opacity, 1 ); element.draggable( "option", "opacity", 0.5 ); - draggableTestHelpers.move( element, 2, 1 ); + testHelper.move( element, 2, 1 ); equal( opacity, 0.5 ); element.draggable( "option", "opacity", false ); - draggableTestHelpers.move( element, 3, 1 ); + testHelper.move( element, 3, 1 ); equal( opacity, 1 ); }); @@ -1006,13 +1006,13 @@ asyncTest( "revert and revertDuration", function() { revert: true, revertDuration: 0 }); - draggableTestHelpers.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" ); + testHelper.shouldMovePositionButNotOffset( element, "revert: true, revertDuration: 0 should revert immediately" ); $( "#draggable2" ).draggable( "option", "revert", "invalid" ); - draggableTestHelpers.shouldMovePositionButNotOffset( element, "revert: invalid, revertDuration: 0 should revert immediately" ); + testHelper.shouldMovePositionButNotOffset( element, "revert: invalid, revertDuration: 0 should revert immediately" ); $( "#draggable2" ).draggable( "option", "revert", false ); - draggableTestHelpers.shouldMove( element, "revert: false should allow movement" ); + testHelper.shouldMove( element, "revert: false should allow movement" ); $( "#draggable2" ).draggable( "option", { revert: true, @@ -1023,7 +1023,7 @@ asyncTest( "revert and revertDuration", function() { }); // animation are async, so test for it asynchronously - draggableTestHelpers.move( element, 50, 50 ); + testHelper.move( element, 50, 50 ); setTimeout( function() { ok( $( "#draggable2" ).is( ":animated" ), "revert: true with revertDuration should animate" ); }); @@ -1039,7 +1039,7 @@ test( "revert: valid", function() { $( "#droppable" ).droppable(); - draggableTestHelpers.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" ); + testHelper.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable" ); }); test( "scope", function() { @@ -1053,17 +1053,17 @@ test( "scope", function() { $( "#droppable" ).droppable({ scope: "tasks" }); - draggableTestHelpers.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" ); + testHelper.shouldMovePositionButNotOffset( element, "revert: valid reverts when dropped on a droppable in scope" ); $( "#droppable" ).droppable( "destroy" ).droppable({ scope: "nottasks" }); - draggableTestHelpers.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" ); + testHelper.shouldMove( element, "revert: valid reverts when dropped on a droppable out of scope" ); }); test( "scroll, scrollSensitivity, and scrollSpeed", function() { expect( 2 ); - draggableTestHelpers.setScrollable( "#main", false ); + testHelper.setScrollable( "#main", false ); var currentScrollTop, viewportHeight = $( window ).height(), @@ -1105,7 +1105,7 @@ test( "scroll, scrollSensitivity, and scrollSpeed", function() { moves: 1 }); - draggableTestHelpers.restoreScroll( document ); + testHelper.restoreScroll( document ); }); test( "scroll ignores containers that are overflow: hidden", function() { @@ -1144,7 +1144,7 @@ test( "scroll ignores containers that are overflow: hidden", function() { test( "#6817: auto scroll goes double distance when dragging", function( assert ) { expect( 2 ); - draggableTestHelpers.restoreScroll( document ); + testHelper.restoreScroll( document ); var offsetBefore, distance = 10, @@ -1175,7 +1175,7 @@ test( "#6817: auto scroll goes double distance when dragging", function( assert moves: 1 }); - draggableTestHelpers.restoreScroll( document ); + testHelper.restoreScroll( document ); }); test( "snap, snapMode, and snapTolerance", function( assert ) { @@ -1337,7 +1337,7 @@ test( "#8459: element can snap to an element that was removed during drag", func }); // Support: Opera 12.10, Safari 5.1, jQuery <1.8 - if ( draggableTestHelpers.unreliableContains ) { + if ( testHelper.unreliableContains ) { ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); ok( true, "Opera <12.14 and Safari <6.0 report wrong values for $.contains in jQuery < 1.8" ); } else { @@ -1394,10 +1394,10 @@ test( "stack", function() { stack: "#draggable1, #draggable2" }); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( element.css( "zIndex" ), "2", "stack increments zIndex correctly" ); - draggableTestHelpers.move( element2, 1, 1 ); + testHelper.move( element2, 1, 1 ); equal( element2.css( "zIndex" ), "3", "stack increments zIndex correctly" ); }); @@ -1435,15 +1435,15 @@ test( "zIndex, default, switching after initialization", function() { element.css( "z-index", 1 ); - draggableTestHelpers.move( element, 1, 1 ); + testHelper.move( element, 1, 1 ); equal( zindex, 1 ); element.draggable( "option", "zIndex", 5 ); - draggableTestHelpers.move( element, 2, 1 ); + testHelper.move( element, 2, 1 ); equal( zindex, 5 ); element.draggable( "option", "zIndex", false ); - draggableTestHelpers.move( element, 3, 1 ); + testHelper.move( element, 3, 1 ); equal( zindex, 1 ); }); diff --git a/tests/unit/draggable/draggable_test_helpers.js b/tests/unit/draggable/draggable_test_helpers.js index dcf2d6297..1858e187b 100644 --- a/tests/unit/draggable/draggable_test_helpers.js +++ b/tests/unit/draggable/draggable_test_helpers.js @@ -1,14 +1,20 @@ -define( function() { +define( [ + "jquery", + "lib/helper", + "ui/draggable" +], function( $, helper ) { -var draggableTestHelpers = { +return $.extend( helper, { // TODO: remove the unreliable offset hacks unreliableOffset: $.ui.ie && ( !document.documentMode || document.documentMode < 8 ) ? 2 : 0, // Support: Opera 12.10, Safari 5.1, jQuery <1.8 + unreliableContains: (function() { var element = $( "<div>" ); return $.contains( element[ 0 ].ownerDocument, element[ 0 ] ); })(), + testDragPosition: function( el, dx, dy, expectedDX, expectedDY, msg ) { msg = msg ? msg + "." : ""; @@ -17,6 +23,7 @@ var draggableTestHelpers = { deepEqual( ui.position, positionExpected, "position dragged[" + dx + ", " + dy + "] " + msg ); }); }, + testDragOffset: function( el, dx, dy, expectedDX, expectedDY, msg ) { msg = msg ? msg + "." : ""; @@ -27,6 +34,7 @@ var draggableTestHelpers = { deepEqual( ui.offset, offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg ); }); }, + testDragHelperOffset: function( el, dx, dy, expectedDX, expectedDY, msg ) { msg = msg ? msg + "." : ""; @@ -37,33 +45,38 @@ var draggableTestHelpers = { deepEqual( ui.helper.offset(), offsetExpected, "offset dragged[" + dx + ", " + dy + "] " + msg ); }); }, + testDrag: function( el, handle, dx, dy, expectedDX, expectedDY, msg ) { - draggableTestHelpers.testDragPosition( el, dx, dy, expectedDX, expectedDY, msg ); - draggableTestHelpers.testDragOffset( el, dx, dy, expectedDX, expectedDY, msg ); + this.testDragPosition( el, dx, dy, expectedDX, expectedDY, msg ); + this.testDragOffset( el, dx, dy, expectedDX, expectedDY, msg ); $( handle ).simulate( "drag", { dx: dx, dy: dy }); }, + shouldMovePositionButNotOffset: function( el, msg, handle ) { handle = handle || el; - draggableTestHelpers.testDragPosition( el, 100, 100, 100, 100, msg ); - draggableTestHelpers.testDragHelperOffset( el, 100, 100, 0, 0, msg ); + this.testDragPosition( el, 100, 100, 100, 100, msg ); + this.testDragHelperOffset( el, 100, 100, 0, 0, msg ); $( handle ).simulate( "drag", { dx: 100, dy: 100 }); }, + shouldMove: function( el, msg, handle ) { handle = handle || el; - draggableTestHelpers.testDrag( el, handle, 100, 100, 100, 100, msg ); + this.testDrag( el, handle, 100, 100, 100, 100, msg ); }, + shouldNotMove: function( el, msg, handle ) { handle = handle || el; - draggableTestHelpers.testDrag( el, handle, 100, 100, 0, 0, msg ); + this.testDrag( el, handle, 100, 100, 0, 0, msg ); }, + shouldNotDrag: function( el, msg, handle ) { handle = handle || el; @@ -89,39 +102,48 @@ var draggableTestHelpers = { element.unbind( "dragstop" ); }, + setScrollable: function( what, isScrollable ) { var overflow = isScrollable ? "scroll" : "hidden"; $( what ).css({ overflow: overflow, overflowX: overflow, overflowY: overflow }); }, + testScroll: function( el, position ) { var oldPosition = $( "#main" ).css( "position" ); $( "#main" ).css({ position: position, top: "0px", left: "0px" }); - draggableTestHelpers.shouldMove( el, position + " parent" ); + this.shouldMove( el, position + " parent" ); $( "#main" ).css( "position", oldPosition ); }, + restoreScroll: function( what ) { $( what ).scrollTop( 0 ).scrollLeft( 0 ); }, + setScroll: function( what ) { $( what ).scrollTop( 100 ).scrollLeft( 100 ); }, + border: function( el, side ) { return parseInt( el.css( "border-" + side + "-width" ), 10 ) || 0; }, + margin: function( el, side ) { return parseInt( el.css( "margin-" + side ), 10 ) || 0; }, + move: function( el, x, y ) { $( el ).simulate( "drag", { dx: x, dy: y }); }, + trackMouseCss: function( el ) { el.bind( "drag", function() { el.data( "last_dragged_cursor", $( "body" ).css( "cursor" ) ); }); }, + trackAppendedParent: function( el ) { // TODO: appendTo is currently ignored if helper is original (see #7044) el.draggable( "option", "helper", "clone" ); @@ -131,8 +153,6 @@ var draggableTestHelpers = { el.data( "last_dragged_parent", ui.helper.parent()[ 0 ] ); }); } -}; - -return draggableTestHelpers; +} ); } ); diff --git a/tests/unit/droppable/droppable_core.js b/tests/unit/droppable/droppable_core.js index 9ea789544..25d052a59 100644 --- a/tests/unit/droppable/droppable_core.js +++ b/tests/unit/droppable/droppable_core.js @@ -2,7 +2,7 @@ define( [ "jquery", "./droppable_test_helpers", "ui/droppable" -], function( $, droppableTestHelpers ) { +], function( $, testHelper ) { module("droppable: core"); @@ -20,7 +20,7 @@ test("element types", function() { (typeName === "table" && el.append("<tr><td>content</td></tr>")); el.droppable(); - droppableTestHelpers.shouldDrop(); + testHelper.shouldDrop(); el.droppable("destroy"); el.remove(); }); diff --git a/tests/unit/droppable/droppable_methods.js b/tests/unit/droppable/droppable_methods.js index 70a60d2cb..816fed0ec 100644 --- a/tests/unit/droppable/droppable_methods.js +++ b/tests/unit/droppable/droppable_methods.js @@ -2,7 +2,7 @@ define( [ "jquery", "./droppable_test_helpers", "ui/droppable" -], function( $, droppableTestHelpers ) { +], function( $, testHelper ) { module("droppable: methods"); @@ -48,16 +48,16 @@ test("enable", function() { var el, expected, actual; el = $("#droppable1").droppable({ disabled: true }); - droppableTestHelpers.shouldNotDrop(); + testHelper.shouldNotDrop(); el.droppable("enable"); - droppableTestHelpers.shouldDrop(); + testHelper.shouldDrop(); equal(el.droppable("option", "disabled"), false, "disabled option getter"); el.droppable("destroy"); el.droppable({ disabled: true }); - droppableTestHelpers.shouldNotDrop(); + testHelper.shouldNotDrop(); el.droppable("option", "disabled", false); equal(el.droppable("option", "disabled"), false, "disabled option setter"); - droppableTestHelpers.shouldDrop(); + testHelper.shouldDrop(); expected = $("<div></div>").droppable(), actual = expected.droppable("enable"); @@ -70,19 +70,19 @@ test( "disable", function( assert ) { var actual, expected, element = $( "#droppable1" ).droppable({ disabled: false }); - droppableTestHelpers.shouldDrop(); + testHelper.shouldDrop(); element.droppable( "disable" ); - droppableTestHelpers.shouldNotDrop(); + testHelper.shouldNotDrop(); equal( element.droppable( "option", "disabled" ), true, "disabled option getter" ); element.droppable( "destroy" ); element.droppable({ disabled: false }); - droppableTestHelpers.shouldDrop(); + testHelper.shouldDrop(); element.droppable( "option", "disabled", true ); assert.lacksClasses( element.droppable( "widget" ), "ui-state-disabled" ); ok( !element.droppable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); assert.hasClasses( element.droppable( "widget" ), "ui-droppable-disabled" ); equal( element.droppable( "option", "disabled" ), true, "disabled option setter" ); - droppableTestHelpers.shouldNotDrop(); + testHelper.shouldNotDrop(); expected = $( "<div></div>" ).droppable(); actual = expected.droppable( "disable" ); diff --git a/tests/unit/droppable/droppable_options.js b/tests/unit/droppable/droppable_options.js index 24a1a788e..f2d1757c2 100644 --- a/tests/unit/droppable/droppable_options.js +++ b/tests/unit/droppable/droppable_options.js @@ -1,6 +1,5 @@ define( [ "jquery", - "./droppable_test_helpers", "ui/droppable" ], function( $ ) { diff --git a/tests/unit/droppable/droppable_test_helpers.js b/tests/unit/droppable/droppable_test_helpers.js index 5ffb32f4c..460fa1aa6 100644 --- a/tests/unit/droppable/droppable_test_helpers.js +++ b/tests/unit/droppable/droppable_test_helpers.js @@ -1,14 +1,18 @@ -define( function() { +define( [ + "jquery", + "lib/helper" +], function( $, helper ) { -return { +return $.extend( helper, { shouldDrop: function() { // todo: actually implement this ok(true, "missing test - untested code is broken code"); }, + shouldNotDrop: function() { // todo: actually implement this ok(true, "missing test - untested code is broken code"); } -}; +} ); } ); diff --git a/tests/unit/menu/menu_core.js b/tests/unit/menu/menu_core.js index 3dd2c78e1..7ff127009 100644 --- a/tests/unit/menu/menu_core.js +++ b/tests/unit/menu/menu_core.js @@ -2,7 +2,7 @@ define( [ "jquery", "./menu_test_helpers", "ui/menu" -], function( $, menuTestHelpers ) { +], function( $, testHelper ) { module( "menu: core" ); @@ -51,7 +51,7 @@ asyncTest( "#9044: Autofocus issue with dialog opened from menu widget", functio $( "#test9044" ).focus(); }); - menuTestHelpers.click( element, "3" ); + testHelper.click( element, "3" ); setTimeout( function() { equal( document.activeElement.id, "test9044", "Focus was swallowed by menu" ); $( "#test9044" ).remove(); diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js index 9aed1839c..9e0e0a2b7 100644 --- a/tests/unit/menu/menu_events.js +++ b/tests/unit/menu/menu_events.js @@ -2,15 +2,15 @@ define( [ "jquery", "./menu_test_helpers", "ui/menu" -], function( $, menuTestHelpers ) { +], function( $, testHelper ) { -var log = menuTestHelpers.log, - logOutput = menuTestHelpers.logOutput, - click = menuTestHelpers.click; +var log = testHelper.log, + logOutput = testHelper.logOutput, + click = testHelper.click; module( "menu: events", { setup: function() { - menuTestHelpers.clearLog(); + testHelper.clearLog(); } }); diff --git a/tests/unit/menu/menu_methods.js b/tests/unit/menu/menu_methods.js index ad30e5f13..61be3229f 100644 --- a/tests/unit/menu/menu_methods.js +++ b/tests/unit/menu/menu_methods.js @@ -2,15 +2,15 @@ define( [ "jquery", "./menu_test_helpers", "ui/menu" -], function( $, menuTestHelpers ) { +], function( $, testHelper ) { -var log = menuTestHelpers.log, - logOutput = menuTestHelpers.logOutput, - click = menuTestHelpers.click; +var log = testHelper.log, + logOutput = testHelper.logOutput, + click = testHelper.click; module( "menu: methods", { setup: function() { - menuTestHelpers.clearLog(); + testHelper.clearLog(); } }); diff --git a/tests/unit/menu/menu_options.js b/tests/unit/menu/menu_options.js index 91630e14b..762b057fb 100644 --- a/tests/unit/menu/menu_options.js +++ b/tests/unit/menu/menu_options.js @@ -2,15 +2,15 @@ define( [ "jquery", "./menu_test_helpers", "ui/menu" -], function( $, menuTestHelpers ) { +], function( $, testHelper ) { -var log = menuTestHelpers.log, - logOutput = menuTestHelpers.logOutput, - click = menuTestHelpers.click; +var log = testHelper.log, + logOutput = testHelper.logOutput, + click = testHelper.click; module( "menu: options", { setup: function() { - menuTestHelpers.clearLog(); + testHelper.clearLog(); } }); diff --git a/tests/unit/menu/menu_test_helpers.js b/tests/unit/menu/menu_test_helpers.js index bfed14d74..445663985 100644 --- a/tests/unit/menu/menu_test_helpers.js +++ b/tests/unit/menu/menu_test_helpers.js @@ -1,9 +1,12 @@ -define( function() { +define( [ + "jquery", + "lib/helper" +], function( $, helper ) { var lastItem, log = []; -return { +return $.extend( helper, { log: function( message, clear ) { if ( clear ) { log.length = 0; @@ -28,6 +31,6 @@ return { .children( ".ui-menu-item-wrapper" ) .trigger( "click" ); } -}; +} ); } ); diff --git a/tests/unit/resizable/resizable_core.js b/tests/unit/resizable/resizable_core.js index 2e643c967..a63189511 100644 --- a/tests/unit/resizable/resizable_core.js +++ b/tests/unit/resizable/resizable_core.js @@ -2,7 +2,7 @@ define( [ "jquery", "./resizable_test_helpers", "ui/resizable" -], function( $, resizableTestHelpers ) { +], function( $, testHelper ) { module("resizable: core"); @@ -30,10 +30,10 @@ test("n", function() { var handle = ".ui-resizable-n", target = $("#resizable1").resizable({ handles: "all" }); - resizableTestHelpers.drag(handle, 0, -50); + testHelper.drag(handle, 0, -50); equal( target.height(), 150, "compare height" ); - resizableTestHelpers.drag(handle, 0, 50); + testHelper.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" }); - resizableTestHelpers.drag(handle, 0, 50); + testHelper.drag(handle, 0, 50); equal( target.height(), 150, "compare height" ); - resizableTestHelpers.drag(handle, 0, -50); + testHelper.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" }); - resizableTestHelpers.drag(handle, 50); + testHelper.drag(handle, 50); equal( target.width(), 150, "compare width"); - resizableTestHelpers.drag(handle, -50); + testHelper.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" }); - resizableTestHelpers.drag(handle, -50); + testHelper.drag(handle, -50); equal( target.width(), 150, "compare width" ); - resizableTestHelpers.drag(handle, 50); + testHelper.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" }); - resizableTestHelpers.drag(handle, -50, -50); + testHelper.drag(handle, -50, -50); equal( target.width(), 50, "compare width" ); equal( target.height(), 150, "compare height" ); - resizableTestHelpers.drag(handle, 50, 50); + testHelper.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" }); - resizableTestHelpers.drag(handle, 50, 50); + testHelper.drag(handle, 50, 50); equal( target.width(), 150, "compare width" ); equal( target.height(), 150, "compare height" ); - resizableTestHelpers.drag(handle, -50, -50); + testHelper.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" }); - resizableTestHelpers.drag(handle, -50, -50); + testHelper.drag(handle, -50, -50); equal( target.width(), 150, "compare width" ); equal( target.height(), 50, "compare height" ); - resizableTestHelpers.drag(handle, 50, 50); + testHelper.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" }); - resizableTestHelpers.drag(handle, -50, -50); + testHelper.drag(handle, -50, -50); equal( target.width(), 150, "compare width" ); equal( target.height(), 150, "compare height" ); - resizableTestHelpers.drag(handle, 50, 50); + testHelper.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" }); - resizableTestHelpers.drag(handle, -50); + testHelper.drag(handle, -50); equal( target.width(), 150, "compare width" ); - resizableTestHelpers.drag(handle, 50); + testHelper.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"); - resizableTestHelpers.drag(handle, 50, 50); + 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" ); @@ -203,7 +203,7 @@ test( "resizable stores correct size when using helper and grid (#9547)", functi grid: [ 10, 10 ] }); - resizableTestHelpers.drag( handle, 1, 1 ); + testHelper.drag( handle, 1, 1 ); equal( target.width(), 100, "compare width" ); equal( target.height(), 100, "compare height" ); }); @@ -227,14 +227,14 @@ test( "nested resizable", function() { innerHandle = $( "#inner > .ui-resizable-e" ); outerHandle = $( "#outer > .ui-resizable-e" ); - resizableTestHelpers.drag( innerHandle, 10 ); + testHelper.drag( innerHandle, 10 ); equal( inner.width(), 40, "compare width of inner element" ); - resizableTestHelpers.drag( innerHandle, -10 ); + testHelper.drag( innerHandle, -10 ); equal( inner.width(), 30, "compare width of inner element" ); - resizableTestHelpers.drag( outerHandle, 10 ); + testHelper.drag( outerHandle, 10 ); equal( outer.width(), 60, "compare width of outer element" ); - resizableTestHelpers.drag( outerHandle, -10 ); + testHelper.drag( outerHandle, -10 ); equal( outer.width(), 50, "compare width of outer element" ); inner.remove(); diff --git a/tests/unit/resizable/resizable_events.js b/tests/unit/resizable/resizable_events.js index 62f258239..a26824137 100644 --- a/tests/unit/resizable/resizable_events.js +++ b/tests/unit/resizable/resizable_events.js @@ -2,7 +2,7 @@ define( [ "jquery", "./resizable_test_helpers", "ui/resizable" -], function( $, resizableTestHelpers ) { +], function( $, testHelper ) { module("resizable: events"); @@ -24,7 +24,7 @@ test("start", function() { } }); - resizableTestHelpers.drag(handle, 50, 50); + testHelper.drag(handle, 50, 50); equal(count, 1, "start callback should happen exactly once"); @@ -55,7 +55,7 @@ test( "resize", function() { } }); - resizableTestHelpers.drag( handle, 50, 50 ); + testHelper.drag( handle, 50, 50 ); equal( count, 2, "resize callback should happen exactly once per size adjustment" ); @@ -83,7 +83,7 @@ test( "resize (min/max dimensions)", function() { } }); - resizableTestHelpers.drag( handle, -200, -200 ); + testHelper.drag( handle, -200, -200 ); equal( count, 1, "resize callback should happen exactly once per size adjustment" ); @@ -113,10 +113,10 @@ test( "resize (containment)", function() { }); // Prove you can't resize outside containment by dragging southeast corner southeast - resizableTestHelpers.drag( handle, 100, 100 ); + testHelper.drag( handle, 100, 100 ); // Prove you can't resize outside containment by dragging southeast corner northwest - resizableTestHelpers.drag( handle, -200, -200 ); + testHelper.drag( handle, -200, -200 ); equal( count, 1, "resize callback should happen exactly once per size adjustment" ); @@ -141,7 +141,7 @@ test("resize (grid)", function() { } }); - resizableTestHelpers.drag(handle, 50, 50); + testHelper.drag(handle, 50, 50); equal(count, 1, "resize callback should happen exactly once per grid-unit size adjustment"); @@ -160,7 +160,7 @@ test( "resize, custom adjustment", function() { } }); - resizableTestHelpers.drag( handle, 50, 50 ); + testHelper.drag( handle, 50, 50 ); equal( element.width(), 100, "resize event can control width" ); equal( element.height(), 200, "resize event can control height" ); @@ -186,7 +186,7 @@ test("stop", function() { } }); - resizableTestHelpers.drag(handle, 50, 50); + testHelper.drag(handle, 50, 50); equal(count, 1, "stop callback should happen exactly once"); @@ -231,7 +231,7 @@ test( "resize (containment) works with parent with negative offset", function() widthBefore = target.width(); - resizableTestHelpers.drag( handle, increaseWidthBy, 0 ); + testHelper.drag( handle, increaseWidthBy, 0 ); widthAfter = target.width(); diff --git a/tests/unit/resizable/resizable_options.js b/tests/unit/resizable/resizable_options.js index c296fe38c..bf9033f13 100644 --- a/tests/unit/resizable/resizable_options.js +++ b/tests/unit/resizable/resizable_options.js @@ -2,7 +2,7 @@ define( [ "jquery", "./resizable_test_helpers", "ui/resizable" -], function( $, resizableTestHelpers ) { +], function( $, testHelper ) { module("resizable: options"); @@ -20,7 +20,7 @@ test( "alsoResize", function() { }), handle = ".ui-resizable-e"; - resizableTestHelpers.drag( handle, 80 ); + testHelper.drag( handle, 80 ); equal( element.width(), 180, "resizable width" ); equal( other.width(), 130, "alsoResize width" ); }); @@ -30,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 }); - resizableTestHelpers.drag(handle, 80); + testHelper.drag(handle, 80); equal( target.width(), 130, "compare maxWidth"); equal( target.height(), 130, "compare maxHeight"); - resizableTestHelpers.drag(handle, -130); + testHelper.drag(handle, -130); equal( target.width(), 70, "compare minWidth"); equal( target.height(), 70, "compare minHeight"); }); @@ -44,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 }); - resizableTestHelpers.drag(handle, -80); + testHelper.drag(handle, -80); equal( target.width(), 130, "compare maxWidth"); equal( target.height(), 130, "compare maxHeight"); - resizableTestHelpers.drag(handle, 130); + testHelper.drag(handle, 130); equal( target.width(), 70, "compare minWidth"); equal( target.height(), 70, "compare minHeight"); }); @@ -58,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 }); - resizableTestHelpers.drag(handle, 0, -80); + testHelper.drag(handle, 0, -80); equal( target.width(), 130, "compare maxWidth"); equal( target.height(), 130, "compare maxHeight"); - resizableTestHelpers.drag(handle, 0, 80); + testHelper.drag(handle, 0, 80); equal( target.width(), 70, "compare minWidth"); equal( target.height(), 70, "compare minHeight"); }); @@ -72,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 }); - resizableTestHelpers.drag(handle, 0, 80); + testHelper.drag(handle, 0, 80); equal( target.width(), 130, "compare maxWidth"); equal( target.height(), 130, "compare maxHeight"); - resizableTestHelpers.drag(handle, 0, -80); + testHelper.drag(handle, 0, -80); equal( target.width(), 70, "compare minWidth"); equal( target.height(), 70, "compare minHeight"); }); @@ -86,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 }); - resizableTestHelpers.drag(handle, 80, 80); + testHelper.drag(handle, 80, 80); equal( target.width(), 130, "compare maxWidth"); equal( target.height(), 130, "compare maxHeight"); - resizableTestHelpers.drag(handle, -80, -80); + testHelper.drag(handle, -80, -80); equal( target.width(), 70, "compare minWidth"); equal( target.height(), 70, "compare minHeight"); }); @@ -100,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 }); - resizableTestHelpers.drag(handle, -80, 80); + testHelper.drag(handle, -80, 80); equal( target.width(), 130, "compare maxWidth"); equal( target.height(), 130, "compare maxHeight"); - resizableTestHelpers.drag(handle, 80, -80); + testHelper.drag(handle, 80, -80); equal( target.width(), 70, "compare minWidth"); equal( target.height(), 70, "compare minHeight"); }); @@ -114,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 }); - resizableTestHelpers.drag(handle, 80, -80); + testHelper.drag(handle, 80, -80); equal( target.width(), 130, "compare maxWidth"); equal( target.height(), 130, "compare maxHeight"); - resizableTestHelpers.drag(handle, -80, 80); + testHelper.drag(handle, -80, 80); equal( target.width(), 70, "compare minWidth"); equal( target.height(), 70, "compare minHeight"); }); @@ -138,7 +138,7 @@ test( "aspectRatio: Resizing can move objects", function() { $( "#container" ).css({ width: 200, height: 300 }); $( "#resizable1" ).css({ width: 100, height: 100, left: 75, top: 200 }); - resizableTestHelpers.drag( handleW, -20 ); + 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" ); @@ -147,7 +147,7 @@ test( "aspectRatio: Resizing can move objects", function() { $( "#container" ).css({ width: 200, height: 300, position: "absolute", left: 100, top: 100 }); $( "#resizable1" ).css({ width: 100, height: 100, left: 0, top: 0 }); - resizableTestHelpers.drag( handleNW, -20, -20 ); + 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" ); @@ -161,11 +161,11 @@ test( "containment", function() { containment: "#container" }); - resizableTestHelpers.drag( ".ui-resizable-se", 20, 30 ); + testHelper.drag( ".ui-resizable-se", 20, 30 ); equal( element.width(), 120, "unconstrained width within container" ); equal( element.height(), 130, "unconstrained height within container" ); - resizableTestHelpers.drag( ".ui-resizable-se", 400, 400 ); + 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" ); }); @@ -180,10 +180,10 @@ test( "containment - not immediate parent", function() { handles: "all" }); - resizableTestHelpers.drag( ".ui-resizable-e", 300, 0 ); + testHelper.drag( ".ui-resizable-e", 300, 0 ); equal( element.width(), 400, "Relative, contained within container width" ); - resizableTestHelpers.drag( ".ui-resizable-s", 0, 300 ); + testHelper.drag( ".ui-resizable-s", 0, 300 ); equal( element.height(), 400, "Relative, contained within container height" ); $( "#child" ).css( { left: 50, top: 50 } ); @@ -195,10 +195,10 @@ test( "containment - not immediate parent", function() { handles: "all" }); - resizableTestHelpers.drag( ".ui-resizable-e", 400, 0 ); + testHelper.drag( ".ui-resizable-e", 400, 0 ); equal( element.width(), 300, "Relative with Left, contained within container width" ); - resizableTestHelpers.drag( ".ui-resizable-s", 0, 400 ); + testHelper.drag( ".ui-resizable-s", 0, 400 ); equal( element.height(), 300, "Relative with Top, contained within container height" ); }); @@ -212,10 +212,10 @@ test( "containment - immediate parent", function() { handles: "all" }); - resizableTestHelpers.drag( ".ui-resizable-e", 400, 0 ); + testHelper.drag( ".ui-resizable-e", 400, 0 ); equal( element.width(), 300, "Relative, contained within container width" ); - resizableTestHelpers.drag( ".ui-resizable-s", 0, 400 ); + testHelper.drag( ".ui-resizable-s", 0, 400 ); equal( element.height(), 300, "Relative, contained within container height" ); $( "#child" ).css( { left: 50, top: 50 } ); @@ -227,10 +227,10 @@ test( "containment - immediate parent", function() { handles: "all" }); - resizableTestHelpers.drag( ".ui-resizable-e", 400, 0 ); + testHelper.drag( ".ui-resizable-e", 400, 0 ); equal( element.width(), 250, "Relative with Left, contained within container width" ); - resizableTestHelpers.drag( ".ui-resizable-s", 0, 400 ); + testHelper.drag( ".ui-resizable-s", 0, 400 ); equal( element.height(), 250, "Relative with Top, contained within container height" ); }); @@ -239,11 +239,11 @@ test("grid", function() { var handle = ".ui-resizable-se", target = $("#resizable1").resizable({ handles: "all", grid: [ 0, 20 ] }); - resizableTestHelpers.drag(handle, 3, 9); + testHelper.drag(handle, 3, 9); equal( target.width(), 103, "compare width"); equal( target.height(), 100, "compare height"); - resizableTestHelpers.drag(handle, 15, 11); + testHelper.drag(handle, 15, 11); equal( target.width(), 118, "compare width"); equal( target.height(), 120, "compare height"); }); @@ -253,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 }); - resizableTestHelpers.drag(handle, 50, 50); + testHelper.drag(handle, 50, 50); equal( target.width(), 120, "grid should respect maxWidth"); equal( target.height(), 120, "grid should respect maxHeight"); - resizableTestHelpers.drag(handle, -100, -100); + testHelper.drag(handle, -100, -100); equal( target.width(), 80, "grid should respect minWidth"); equal( target.height(), 80, "grid should respect minHeight"); }); @@ -267,11 +267,11 @@ test("grid (wrapped)", function() { var handle = ".ui-resizable-se", target = $("#resizable2").resizable({ handles: "all", grid: [ 0, 20 ] }); - resizableTestHelpers.drag(handle, 3, 9); + testHelper.drag(handle, 3, 9); equal( target.width(), 103, "compare width"); equal( target.height(), 100, "compare height"); - resizableTestHelpers.drag(handle, 15, 11); + testHelper.drag(handle, 15, 11); equal( target.width(), 118, "compare width"); equal( target.height(), 120, "compare height"); }); @@ -286,13 +286,13 @@ test( "grid - Resizable: can be moved when grid option is set (#9611)", function grid: 50 }); - resizableTestHelpers.drag( handle, 50, 50 ); + testHelper.drag( handle, 50, 50 ); equal( target.width(), 50, "compare width" ); equal( target.height(), 50, "compare height" ); oldPosition = target.position(); - resizableTestHelpers.drag( handle, 50, 50 ); + 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" ); @@ -314,7 +314,7 @@ test( "grid - maintains grid with padding and border when approaching no dimensi grid: [ 50, 12 ] }); - resizableTestHelpers.drag( handle, 50, 50 ); + testHelper.drag( handle, 50, 50 ); equal( target.outerWidth(), 50, "compare width" ); equal( target.outerHeight(), 52, "compare height" ); }); @@ -324,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 }); - resizableTestHelpers.drag(handle, -50, -50); + testHelper.drag(handle, -50, -50); equal( target.width(), 60, "compare minWidth" ); equal( target.height(), 60, "compare minHeight" ); - resizableTestHelpers.drag(handle, 70, 70); + testHelper.drag(handle, 70, 70); equal( target.width(), 100, "compare maxWidth" ); equal( target.height(), 100, "compare maxHeight" ); }); @@ -338,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 }); - resizableTestHelpers.drag(handle, 50, -50); + testHelper.drag(handle, 50, -50); equal( target.width(), 60, "compare minWidth" ); equal( target.height(), 60, "compare minHeight" ); - resizableTestHelpers.drag(handle, -70, 70); + testHelper.drag(handle, -70, 70); equal( target.width(), 100, "compare maxWidth" ); equal( target.height(), 100, "compare maxHeight" ); }); @@ -352,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 }); - resizableTestHelpers.drag(handle, -50, 50); + testHelper.drag(handle, -50, 50); equal( target.width(), 60, "compare minWidth" ); equal( target.height(), 60, "compare minHeight" ); - resizableTestHelpers.drag(handle, 70, -70); + testHelper.drag(handle, 70, -70); equal( target.width(), 100, "compare maxWidth" ); equal( target.height(), 100, "compare maxHeight" ); }); @@ -366,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 }); - resizableTestHelpers.drag(handle, 70, 70); + testHelper.drag(handle, 70, 70); equal( target.width(), 60, "compare minWidth" ); equal( target.height(), 60, "compare minHeight" ); - resizableTestHelpers.drag(handle, -70, -70); + testHelper.drag(handle, -70, -70); equal( target.width(), 100, "compare maxWidth" ); equal( target.height(), 100, "compare maxHeight" ); }); @@ -382,10 +382,10 @@ test( "custom handles { handles: { 's': $('#resizer1'), containment: 'parent' }" var handle = "#resizer1", target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" ) }, containment: "parent" }); - resizableTestHelpers.drag( handle, 0, 70 ); + testHelper.drag( handle, 0, 70 ); equal( target.height(), 170, "compare height" ); - resizableTestHelpers.drag( handle, 0, -70 ); + testHelper.drag( handle, 0, -70 ); equal( target.height(), 100, "compare height" ); }); @@ -396,10 +396,10 @@ test( "custom handles { handles: { 's': $('#resizer1')[0], containment: 'parent' var handle = "#resizer1", target = $( "#resizable1" ).resizable({ handles: { "s": $( "#resizer1" )[ 0 ] }, containment: "parent" }); - resizableTestHelpers.drag( handle, 0, 70 ); + testHelper.drag( handle, 0, 70 ); equal( target.height(), 170, "compare height" ); - resizableTestHelpers.drag( handle, 0, -70 ); + testHelper.drag( handle, 0, -70 ); equal( target.height(), 100, "compare height" ); }); @@ -426,7 +426,7 @@ test( "alsoResize + containment", function() { containment: "#container" }); - resizableTestHelpers.drag( ".ui-resizable-se", 400, 400 ); + 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" ); @@ -454,7 +454,7 @@ test( "alsoResize + multiple selection", function() { containment: "#container" }); - resizableTestHelpers.drag( ".ui-resizable-se", 400, 400 ); + 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" ); diff --git a/tests/unit/resizable/resizable_test_helpers.js b/tests/unit/resizable/resizable_test_helpers.js index 1c2ec831b..494c1a073 100644 --- a/tests/unit/resizable/resizable_test_helpers.js +++ b/tests/unit/resizable/resizable_test_helpers.js @@ -1,6 +1,9 @@ -define( function() { +define( [ + "jquery", + "lib/helper" +], function( $, helper ) { -return { +return $.extend( helper, { drag: function( el, dx, dy ) { // this mouseover is to work around a limitation in resizable // TODO: fix resizable so handle doesn't require mouseover in order to be used @@ -10,6 +13,6 @@ return { dy: dy }); } -}; +} ); } ); diff --git a/tests/unit/sortable/sortable_core.js b/tests/unit/sortable/sortable_core.js index 0a7506184..64bdb661e 100644 --- a/tests/unit/sortable/sortable_core.js +++ b/tests/unit/sortable/sortable_core.js @@ -2,7 +2,7 @@ define( [ "jquery", "./sortable_test_helpers", "ui/sortable" -], function( $, sortableTestHelpers ) { +], function( $, testHelper ) { module( "sortable: core" ); @@ -13,7 +13,7 @@ test( "#9314: Sortable: Items cannot be dragged directly into bottom position", connectWith: ".connectWith" }); - sortableTestHelpers.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" ); + testHelper.sort( $( "li", el[ 1 ] )[ 0 ], 0, -12, 5, "Dragging the sortable into connected sortable" ); }); test( "ui-sortable-handle applied to appropriate element", function( assert ) { diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index 2bf9efe30..453b8b7b6 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -3,7 +3,7 @@ define( [ "./sortable_test_helpers", "ui/sortable", "ui/draggable" -], function( $, sortableTestHelpers ) { +], function( $, testHelper ) { module("sortable: events"); @@ -172,7 +172,7 @@ test("#3019: Stop fires too early", function() { } }); - sortableTestHelpers.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable"); + testHelper.sort($("li", el)[0], 0, 44, 2, "Dragging the sortable"); equal(helper, null, "helper should be false"); }); diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index b1057fc8e..d3bb23d6e 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -2,7 +2,7 @@ define( [ "jquery", "./sortable_test_helpers", "ui/sortable" -], function( $, sortableTestHelpers ) { +], function( $, testHelper ) { module("sortable: methods"); @@ -48,7 +48,7 @@ test("enable", function() { el = $("#sortable").sortable({ disabled: true }); - sortableTestHelpers.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })"); + testHelper.sort($("li", el)[0], 0, 44, 0, ".sortable({ disabled: true })"); el.sortable("enable"); equal(el.sortable("option", "disabled"), false, "disabled option getter"); @@ -58,7 +58,7 @@ test("enable", function() { el.sortable("option", "disabled", false); equal(el.sortable("option", "disabled"), false, "disabled option setter"); - sortableTestHelpers.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)"); + testHelper.sort($("li", el)[0], 0, 44, 2, ".sortable('option', 'disabled', false)"); expected = $("<div></div>").sortable(), actual = expected.sortable("enable"); @@ -71,15 +71,15 @@ test( "disable", function( assert ) { var chainable, element = $( "#sortable" ).sortable({ disabled: false }); - sortableTestHelpers.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); + testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); chainable = element.sortable( "disable" ); - sortableTestHelpers.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" ); + testHelper.sort( $( "li", element )[ 0 ], 0, 44, 0, "disabled.sortable getter" ); element.sortable( "destroy" ); element.sortable({ disabled: false }); - sortableTestHelpers.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); + testHelper.sort( $( "li", element )[ 0 ], 0, 44, 2, ".sortable({ disabled: false })" ); element.sortable( "option", "disabled", true); equal( element.sortable( "option", "disabled" ), true, "disabled option setter" ); @@ -87,7 +87,7 @@ test( "disable", function( assert ) { ok( !element.sortable( "widget" ).attr( "aria-disabled" ), "element does not get aria-disabled" ); assert.hasClasses( element.sortable( "widget" ), "ui-sortable-disabled" ); - sortableTestHelpers.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" ); + testHelper.sort($( "li", element )[ 0 ], 0, 44, 0, ".sortable('option', 'disabled', true)" ); equal( chainable, element, "disable is chainable" ); }); diff --git a/tests/unit/sortable/sortable_test_helpers.js b/tests/unit/sortable/sortable_test_helpers.js index 5f4f8aca6..76545022e 100644 --- a/tests/unit/sortable/sortable_test_helpers.js +++ b/tests/unit/sortable/sortable_test_helpers.js @@ -1,6 +1,9 @@ -define( function() { +define( [ + "jquery", + "lib/helper" +], function( $, helper ) { -return { +return $.extend( helper, { sort: function( handle, dx, dy, index, msg ) { $( handle ).simulate( "drag", { dx: dx, @@ -8,6 +11,6 @@ return { }); equal( $( handle ).parent().children().index( handle ), index, msg ); } -}; +} ); } ); diff --git a/tests/unit/spinner/spinner_core.js b/tests/unit/spinner/spinner_core.js index 5faa733c3..d0388a575 100644 --- a/tests/unit/spinner/spinner_core.js +++ b/tests/unit/spinner/spinner_core.js @@ -2,9 +2,9 @@ define( [ "jquery", "./spinner_test_helpers", "ui/spinner" -], function( $, spinnerTestHelpers ) { +], function( $, testHelper ) { -var simulateKeyDownUp = spinnerTestHelpers.simulateKeyDownUp; +var simulateKeyDownUp = testHelper.simulateKeyDownUp; module( "spinner: core" ); diff --git a/tests/unit/spinner/spinner_events.js b/tests/unit/spinner/spinner_events.js index 05d1efe1b..a37d61346 100644 --- a/tests/unit/spinner/spinner_events.js +++ b/tests/unit/spinner/spinner_events.js @@ -2,9 +2,9 @@ define( [ "jquery", "./spinner_test_helpers", "ui/spinner" -], function( $, spinnerTestHelpers ) { +], function( $, testHelper ) { -var simulateKeyDownUp = spinnerTestHelpers.simulateKeyDownUp; +var simulateKeyDownUp = testHelper.simulateKeyDownUp; module( "spinner: events" ); diff --git a/tests/unit/spinner/spinner_methods.js b/tests/unit/spinner/spinner_methods.js index 3f88a9e9c..75ae5c9e8 100644 --- a/tests/unit/spinner/spinner_methods.js +++ b/tests/unit/spinner/spinner_methods.js @@ -2,9 +2,9 @@ define( [ "jquery", "./spinner_test_helpers", "ui/spinner" -], function( $, spinnerTestHelpers ) { +], function( $, testHelper ) { -var simulateKeyDownUp = spinnerTestHelpers.simulateKeyDownUp; +var simulateKeyDownUp = testHelper.simulateKeyDownUp; module( "spinner: methods" ); diff --git a/tests/unit/spinner/spinner_test_helpers.js b/tests/unit/spinner/spinner_test_helpers.js index 9ed904ff4..ab99dcd8e 100644 --- a/tests/unit/spinner/spinner_test_helpers.js +++ b/tests/unit/spinner/spinner_test_helpers.js @@ -1,11 +1,14 @@ -define( function() { +define( [ + "jquery", + "lib/helper" +], function( $, helper ) { -return { +return $.extend( helper, { simulateKeyDownUp: function( element, keyCode, shift ) { element .simulate( "keydown", { keyCode: keyCode, shiftKey: shift || false } ) .simulate( "keyup", { keyCode: keyCode, shiftKey: shift || false } ); } -}; +} ); } ); diff --git a/tests/unit/tabs/tabs_core.js b/tests/unit/tabs/tabs_core.js index c7eb23704..2e39ca0e6 100644 --- a/tests/unit/tabs/tabs_core.js +++ b/tests/unit/tabs/tabs_core.js @@ -2,9 +2,9 @@ define( [ "jquery", "./tabs_test_helpers", "ui/tabs" -], function( $, tabsTestHelpers ) { +], function( $, testHelper ) { -var state = tabsTestHelpers.state; +var state = testHelper.state; module( "tabs: core" ); diff --git a/tests/unit/tabs/tabs_events.js b/tests/unit/tabs/tabs_events.js index b5972242d..fb2746248 100644 --- a/tests/unit/tabs/tabs_events.js +++ b/tests/unit/tabs/tabs_events.js @@ -2,9 +2,9 @@ define( [ "jquery", "./tabs_test_helpers", "ui/tabs" -], function( $, tabsTestHelpers ) { +], function( $, testHelper ) { -var state = tabsTestHelpers.state; +var state = testHelper.state; module( "tabs: events" ); diff --git a/tests/unit/tabs/tabs_methods.js b/tests/unit/tabs/tabs_methods.js index cd4ed3581..fc1ff6dd6 100644 --- a/tests/unit/tabs/tabs_methods.js +++ b/tests/unit/tabs/tabs_methods.js @@ -2,10 +2,10 @@ define( [ "jquery", "./tabs_test_helpers", "ui/tabs" -], function( $, tabsTestHelpers ) { +], function( $, testHelper ) { -var disabled = tabsTestHelpers.disabled, - state = tabsTestHelpers.state; +var disabled = testHelper.disabled, + state = testHelper.state; module( "tabs: methods" ); diff --git a/tests/unit/tabs/tabs_options.js b/tests/unit/tabs/tabs_options.js index 13b88b040..e4c3efa15 100644 --- a/tests/unit/tabs/tabs_options.js +++ b/tests/unit/tabs/tabs_options.js @@ -2,11 +2,11 @@ define( [ "jquery", "./tabs_test_helpers", "ui/tabs" -], function( $, tabsTestHelpers ) { +], function( $, testHelper ) { -var disabled = tabsTestHelpers.disabled, - equalHeight = tabsTestHelpers.equalHeight, - state = tabsTestHelpers.state; +var disabled = testHelper.disabled, + equalHeight = testHelper.equalHeight, + state = testHelper.state; module( "tabs: options" ); diff --git a/tests/unit/tabs/tabs_test_helpers.js b/tests/unit/tabs/tabs_test_helpers.js index 8d35c31db..5c9625f8c 100644 --- a/tests/unit/tabs/tabs_test_helpers.js +++ b/tests/unit/tabs/tabs_test_helpers.js @@ -1,6 +1,10 @@ -define( function() { +define( [ + "jquery", + "lib/helper", + "ui/tabs" +], function( $, helper ) { -return { +return $.extend( helper, { disabled: function( tabs, state ) { var expected, actual, internalState = tabs.tabs( "option", "disabled" ); @@ -65,6 +69,6 @@ return { }).get(); deepEqual( actual, expected ); } -}; +} ); } ); |