From 7d168ce6300a4b59f54c7b7f55c622a7a60ba222 Mon Sep 17 00:00:00 2001 From: Scott González Date: Mon, 6 Apr 2015 20:06:31 -0400 Subject: Datepicker: Convert tests to new infrastructure Ref #10119 Ref gh-1528 --- tests/unit/datepicker/datepicker.html | 28 +-- tests/unit/datepicker/datepicker_core.js | 142 ++++++------- tests/unit/datepicker/datepicker_events.js | 23 ++- tests/unit/datepicker/datepicker_methods.js | 49 ++--- tests/unit/datepicker/datepicker_options.js | 253 ++++++++++++----------- tests/unit/datepicker/datepicker_test_helpers.js | 15 +- 6 files changed, 251 insertions(+), 259 deletions(-) (limited to 'tests') diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html index 136bd2f6b..a0df70d74 100644 --- a/tests/unit/datepicker/datepicker.html +++ b/tests/unit/datepicker/datepicker.html @@ -4,32 +4,8 @@ jQuery UI Datepicker Test Suite - - - - - - - - - - - - - - - + + diff --git a/tests/unit/datepicker/datepicker_core.js b/tests/unit/datepicker/datepicker_core.js index 65b07e2f6..3ed4b9487 100644 --- a/tests/unit/datepicker/datepicker_core.js +++ b/tests/unit/datepicker/datepicker_core.js @@ -1,8 +1,10 @@ -/* - * datepicker_core.js - */ - -(function($) { +define( [ + "jquery", + "lib/common", + "./datepicker_test_helpers", + "ui/datepicker", + "ui/i18n/datepicker-he" +], function( $, common, datepickerTestHelpers ) { module( "datepicker: core", { setup: function() { @@ -10,7 +12,7 @@ module( "datepicker: core", { } }); -TestHelpers.testJshint( "datepicker" ); +common.testJshint( "datepicker" ); test("initialization - Reinitialization after body had been emptied.", function() { expect( 1 ); @@ -37,11 +39,11 @@ test("widget method", function() { asyncTest( "baseStructure", function() { expect( 58 ); var header, title, table, thead, week, panel, inl, child, - inp = TestHelpers.datepicker.initNewInput(), + inp = datepickerTestHelpers.initNewInput(), dp = $( "#ui-datepicker-div" ); function step1() { - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.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" ); @@ -82,12 +84,12 @@ asyncTest( "baseStructure", function() { function step2() { // Editable month/year and button panel - inp = TestHelpers.datepicker.initNewInput({ + inp = datepickerTestHelpers.initNewInput({ changeMonth: true, changeYear: true, showButtonPanel: true }); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.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" ); @@ -105,8 +107,8 @@ asyncTest( "baseStructure", function() { function step3() { // Multi-month 2 - inp = TestHelpers.datepicker.initNewInput({ numberOfMonths: 2 }); - TestHelpers.datepicker.onFocus( inp, function() { + inp = datepickerTestHelpers.initNewInput({ numberOfMonths: 2 }); + datepickerTestHelpers.onFocus( inp, function() { ok( dp.is( ".ui-datepicker-multi" ), "Structure multi [2] - multi-month" ); equal( dp.children().length, 3, "Structure multi [2] - child count" ); @@ -127,8 +129,8 @@ asyncTest( "baseStructure", function() { function step4() { // Multi-month 3 - inp = TestHelpers.datepicker.initNewInput({ numberOfMonths: 3 }); - TestHelpers.datepicker.onFocus( inp, function() { + inp = datepickerTestHelpers.initNewInput({ numberOfMonths: 3 }); + datepickerTestHelpers.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" ); @@ -139,8 +141,8 @@ asyncTest( "baseStructure", function() { function step5() { // Multi-month [2, 2] - inp = TestHelpers.datepicker.initNewInput({ numberOfMonths: [ 2, 2 ] }); - TestHelpers.datepicker.onFocus( inp, function() { + inp = datepickerTestHelpers.initNewInput({ numberOfMonths: [ 2, 2 ] }); + datepickerTestHelpers.onFocus( inp, function() { ok( dp.is( ".ui-datepicker-multi" ), "Structure multi - multi-month" ); equal( dp.children().length, 6, "Structure multi [2,2] - child count" ); @@ -165,7 +167,7 @@ asyncTest( "baseStructure", function() { inp.datepicker( "hide" ).datepicker( "destroy" ); // Inline - inl = TestHelpers.datepicker.init( "#inl" ); + inl = datepickerTestHelpers.init( "#inl" ); dp = inl.children(); ok( dp.is( ".ui-datepicker-inline" ), "Structure inline - main div" ); @@ -185,7 +187,7 @@ asyncTest( "baseStructure", function() { inl.datepicker( "destroy" ); // Inline multi-month - inl = TestHelpers.datepicker.init( "#inl", { numberOfMonths: 2 } ); + inl = datepickerTestHelpers.init( "#inl", { numberOfMonths: 2 } ); dp = inl.children(); ok( dp.is( ".ui-datepicker-inline" ) && dp.is( ".ui-datepicker-multi" ), "Structure inline multi - main div" ); @@ -211,13 +213,13 @@ asyncTest( "baseStructure", function() { asyncTest( "customStructure", function() { expect( 20 ); var header, panel, title, thead, - inp = TestHelpers.datepicker.initNewInput( $.datepicker.regional.he ), + inp = datepickerTestHelpers.initNewInput( $.datepicker.regional.he ), dp = $( "#ui-datepicker-div" ); function step1() { inp.datepicker( "option", "showButtonPanel", true ); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.onFocus( inp, function() { ok( dp.is( ".ui-datepicker-rtl" ), "Structure RTL - right-to-left" ); header = dp.children( ":first" ); @@ -239,14 +241,14 @@ asyncTest( "customStructure", function() { // Hide prev/next function step2() { - inp = TestHelpers.datepicker.initNewInput({ + inp = datepickerTestHelpers.initNewInput({ hideIfNoPrevNext: true, minDate: new Date( 2008, 2 - 1, 4 ), maxDate: new Date( 2008, 2 - 1, 14 ) }); inp.val( "02/10/2008" ); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.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" ); @@ -259,9 +261,9 @@ asyncTest( "customStructure", function() { // Changeable Month with read-only year function step3() { - inp = TestHelpers.datepicker.initNewInput({ changeMonth: true }); + inp = datepickerTestHelpers.initNewInput({ changeMonth: true }); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.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" ); @@ -274,9 +276,9 @@ asyncTest( "customStructure", function() { // Changeable year with read-only month function step4() { - inp = TestHelpers.datepicker.initNewInput({ changeYear: true }); + inp = datepickerTestHelpers.initNewInput({ changeYear: true }); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.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" ); @@ -289,9 +291,9 @@ asyncTest( "customStructure", function() { // Read-only first day of week function step5() { - inp = TestHelpers.datepicker.initNewInput({ changeFirstDay: false }); + inp = datepickerTestHelpers.initNewInput({ changeFirstDay: false }); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.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" ); @@ -309,19 +311,19 @@ asyncTest( "customStructure", function() { test("keystrokes", function() { expect( 26 ); - var inp = TestHelpers.datepicker.init("#inp"), + var inp = datepickerTestHelpers.init("#inp"), date = new Date(); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke enter"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Keystroke enter"); inp.val("02/04/2008").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+home"); + datepickerTestHelpers.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"); @@ -330,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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+left"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke left"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+right"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke right"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+up"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke up"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke ctrl+down"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Keystroke down"); + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 4), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 4), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 4), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 4), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 29), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 2 - 1, 28), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 28), + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2009, 2 - 1, 28), "Keystroke ctrl+pgdn - Feb"); // Goto current inp.datepicker("option", {gotoCurrent: true}). @@ -426,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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2007, 12 - 1, 4), + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 4 - 1, 4), + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 4 - 1, 4), "Keystroke pgdn step 2"); }); test("mouse", function() { expect( 15 ); var inl, - inp = TestHelpers.datepicker.init("#inp"), + inp = datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Mouse click"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Mouse click"); inp.val("02/04/2008").datepicker("show"); $(".ui-datepicker-calendar tbody a:contains(12)", dp).simulate("click", {}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 12), + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click - preset"); inp.val("02/04/2008").datepicker("show"); inp.val("").datepicker("show"); @@ -462,67 +464,67 @@ 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", {}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + datepickerTestHelpers.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", {}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 4), + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Mouse click - current"); + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 1 - 1, 16), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 3 - 1, 18), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 16), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 18), + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), new Date(2008, 2 - 1, 18), "Mouse click - next + min/max"); // Inline - inl = TestHelpers.datepicker.init("#inl"); + inl = datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline"); + datepickerTestHelpers.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", {}); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 2 - 1, 12), "Mouse click inline - preset"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date, "Mouse click inline - current"); + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 1 - 1, 16), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), new Date(2008, 3 - 1, 18), + datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), new Date(2008, 3 - 1, 18), "Mouse click inline - next"); }); -})(jQuery); +} ); diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js index dfc42ccf9..b012f647d 100644 --- a/tests/unit/datepicker/datepicker_events.js +++ b/tests/unit/datepicker/datepicker_events.js @@ -1,7 +1,8 @@ -/* - * datepicker_events.js - */ -(function($) { +define( [ + "jquery", + "./datepicker_test_helpers", + "ui/datepicker" +], function( $, datepickerTestHelpers ) { module("datepicker: events"); @@ -24,13 +25,13 @@ function callback2(year, month, inst) { test("events", function() { expect( 26 ); var dateStr, newMonthYear, inp2, - inp = TestHelpers.datepicker.init("#inp", {onSelect: callback}), + inp = datepickerTestHelpers.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], TestHelpers.datepicker.PROP_NAME), "Callback selected inst"); + equal(selectedInst, $.data(inp[0], datepickerTestHelpers.PROP_NAME), "Callback selected inst"); equal(selectedDate, $.datepicker.formatDate("mm/dd/yy", date), "Callback selected date"); inp.val("").datepicker("show"). @@ -59,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], TestHelpers.datepicker.PROP_NAME), "Callback change month/year inst"); + equal(selectedInst, $.data(inp[0], datepickerTestHelpers.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}); @@ -107,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], TestHelpers.datepicker.PROP_NAME), "Callback close inst"); + equal(selectedInst, $.data(inp[0], datepickerTestHelpers.PROP_NAME), "Callback close inst"); equal(selectedDate, "", "Callback close date - esc"); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); @@ -120,7 +121,7 @@ test("events", function() { simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END}); equal(selectedDate, "", "Callback close date - ctrl+end"); - inp2 = TestHelpers.datepicker.init("#inp2"); + inp2 = datepickerTestHelpers.init("#inp2"); inp2.datepicker().datepicker("option", {onClose: callback}).datepicker("show"); inp.datepicker("show"); equal(selectedThis, inp2[0], "Callback close this"); @@ -128,7 +129,7 @@ test("events", function() { test("beforeShowDay-getDate", function() { expect( 3 ); - var inp = TestHelpers.datepicker.init("#inp", {beforeShowDay: function() { inp.datepicker("getDate"); return [true, ""]; }}), + var inp = datepickerTestHelpers.init("#inp", {beforeShowDay: function() { inp.datepicker("getDate"); return [true, ""]; }}), dp = $("#ui-datepicker-div"); inp.val("01/01/2010").datepicker("show"); // contains non-breaking space @@ -150,4 +151,4 @@ test("beforeShowDay-getDate", function() { inp.datepicker("hide"); }); -})(jQuery); +} ); diff --git a/tests/unit/datepicker/datepicker_methods.js b/tests/unit/datepicker/datepicker_methods.js index e52e126d2..c16376880 100644 --- a/tests/unit/datepicker/datepicker_methods.js +++ b/tests/unit/datepicker/datepicker_methods.js @@ -1,72 +1,73 @@ -/* - * datepicker_methods.js - */ -(function($) { +define( [ + "jquery", + "./datepicker_test_helpers", + "ui/datepicker" +], function( $, datepickerTestHelpers ) { module("datepicker: methods"); test("destroy", function() { expect( 33 ); var inl, - inp = TestHelpers.datepicker.init("#inp"); + inp = datepickerTestHelpers.init("#inp"); ok(inp.is(".hasDatepicker"), "Default - marker class set"); - ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Default - instance present"); + ok($.data(inp[0], datepickerTestHelpers.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], TestHelpers.datepicker.PROP_NAME), "Default - instance absent"); + ok(!$.data(inp[0], datepickerTestHelpers.PROP_NAME), "Default - instance absent"); ok(inp.next().is("#alt"), "Default - button absent"); // With button - inp= TestHelpers.datepicker.init("#inp", {showOn: "both"}); + inp= datepickerTestHelpers.init("#inp", {showOn: "both"}); ok(inp.is(".hasDatepicker"), "Button - marker class set"); - ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Button - instance present"); + ok($.data(inp[0], datepickerTestHelpers.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], TestHelpers.datepicker.PROP_NAME), "Button - instance absent"); + ok(!$.data(inp[0], datepickerTestHelpers.PROP_NAME), "Button - instance absent"); ok(inp.next().is("#alt"), "Button - button removed"); // With append text - inp = TestHelpers.datepicker.init("#inp", {appendText: "Testing"}); + inp = datepickerTestHelpers.init("#inp", {appendText: "Testing"}); ok(inp.is(".hasDatepicker"), "Append - marker class set"); - ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Append - instance present"); + ok($.data(inp[0], datepickerTestHelpers.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], TestHelpers.datepicker.PROP_NAME), "Append - instance absent"); + ok(!$.data(inp[0], datepickerTestHelpers.PROP_NAME), "Append - instance absent"); ok(inp.next().is("#alt"), "Append - append text removed"); // With both - inp= TestHelpers.datepicker.init("#inp", {showOn: "both", buttonImageOnly: true, + inp= datepickerTestHelpers.init("#inp", {showOn: "both", buttonImageOnly: true, buttonImage: "images/calendar.gif", appendText: "Testing"}); ok(inp.is(".hasDatepicker"), "Both - marker class set"); - ok($.data(inp[0], TestHelpers.datepicker.PROP_NAME), "Both - instance present"); + ok($.data(inp[0], datepickerTestHelpers.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], TestHelpers.datepicker.PROP_NAME), "Both - instance absent"); + ok(!$.data(inp[0], datepickerTestHelpers.PROP_NAME), "Both - instance absent"); ok(inp.next().is("#alt"), "Both - button and append text absent"); // Inline - inl = TestHelpers.datepicker.init("#inl"); + inl = datepickerTestHelpers.init("#inl"); ok(inl.is(".hasDatepicker"), "Inline - marker class set"); ok(inl.html() !== "", "Inline - datepicker present"); - ok($.data(inl[0], TestHelpers.datepicker.PROP_NAME), "Inline - instance present"); + ok($.data(inl[0], datepickerTestHelpers.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], TestHelpers.datepicker.PROP_NAME), "Inline - instance absent"); + ok(!$.data(inl[0], datepickerTestHelpers.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 = TestHelpers.datepicker.init("#inp"); + inp = datepickerTestHelpers.init("#inp"); ok(!inp.datepicker("isDisabled"), "Enable/disable - initially marked as enabled"); ok(!inp[0].disabled, "Enable/disable - field initially enabled"); inp.datepicker("disable"); @@ -77,7 +78,7 @@ test("enableDisable", function() { ok(!inp[0].disabled, "Enable/disable - field now enabled"); inp.datepicker("destroy"); // With a button - inp = TestHelpers.datepicker.init("#inp", {showOn: "button"}); + inp = datepickerTestHelpers.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"); @@ -91,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 = TestHelpers.datepicker.init("#inp", {showOn: "button", buttonImageOnly: true, + inp = datepickerTestHelpers.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"); @@ -106,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 = TestHelpers.datepicker.init("#inl", {changeYear: true}); + inl = datepickerTestHelpers.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"); @@ -122,4 +123,4 @@ test("enableDisable", function() { inl.datepicker("destroy"); }); -})(jQuery); +} ); diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 08c31f5ad..20a7b4d80 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -1,14 +1,17 @@ -/* - * datepicker_options.js - */ - -(function($) { +define( [ + "jquery", + "./datepicker_test_helpers", + "ui/datepicker", + "ui/i18n/datepicker-fr", + "ui/i18n/datepicker-he", + "ui/i18n/datepicker-zh-CN" +], function( $, datepickerTestHelpers ) { module("datepicker: options"); test("setDefaults", function() { expect( 3 ); - TestHelpers.datepicker.init("#inp"); + datepickerTestHelpers.init("#inp"); equal($.datepicker._defaults.showOn, "focus", "Initial showOn"); $.datepicker.setDefaults({showOn: "button"}); equal($.datepicker._defaults.showOn, "button", "Change default showOn"); @@ -18,8 +21,8 @@ test("setDefaults", function() { test("option", function() { expect( 17 ); - var inp = TestHelpers.datepicker.init("#inp"), - inst = $.data(inp[0], TestHelpers.datepicker.PROP_NAME); + var inp = datepickerTestHelpers.init("#inp"), + inst = $.data(inp[0], datepickerTestHelpers.PROP_NAME); // Set option equal(inst.settings.showOn, null, "Initial setting showOn"); equal($.datepicker._get(inst, "showOn"), "focus", "Initial instance showOn"); @@ -37,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 = TestHelpers.datepicker.init("#inp"); + inp = datepickerTestHelpers.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"); @@ -50,7 +53,7 @@ test("option", function() { test( "disabled", function() { expect(8); - var inp = TestHelpers.datepicker.init("#inp"); + var inp = datepickerTestHelpers.init("#inp"); ok(!inp.datepicker("isDisabled"), "Initially marked as enabled"); ok(!inp[0].disabled, "Field initially enabled"); inp.datepicker("option", "disabled", true); @@ -61,15 +64,15 @@ test( "disabled", function() { ok(!inp[0].disabled, "Field now enabled"); inp.datepicker("destroy"); - inp = TestHelpers.datepicker.init("#inp", { disabled: true }); + inp = datepickerTestHelpers.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 = TestHelpers.datepicker.init("#inp"), - inst = $.data(inp[0], TestHelpers.datepicker.PROP_NAME); + var inp = datepickerTestHelpers.init("#inp"), + inst = $.data(inp[0], datepickerTestHelpers.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"); @@ -104,7 +107,7 @@ test("change", function() { expect( isOldIE ? 25 : 29 ); function step0() { - var inp = TestHelpers.datepicker.initNewInput(), + var inp = datepickerTestHelpers.initNewInput(), dp = $( "#ui-datepicker-div" ); button = inp.siblings( "button" ); @@ -112,7 +115,7 @@ test("change", function() { image = inp.siblings( "img" ); ok( image.length === 0, "Focus - image absent" ); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.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" ); @@ -122,10 +125,10 @@ test("change", function() { function step1() { - var inp = TestHelpers.datepicker.initNewInput(), + var inp = datepickerTestHelpers.initNewInput(), dp = $( "#ui-datepicker-div" ); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.onFocus( inp, function() { ok( dp.is( ":visible" ), "Focus - rendered on focus" ); body.simulate( "mousedown", {} ); ok( !dp.is( ":visible" ), "Focus - hidden on external click" ); @@ -136,7 +139,7 @@ test("change", function() { } function step2() { - var inp = TestHelpers.datepicker.initNewInput({ + var inp = datepickerTestHelpers.initNewInput({ showOn: "button", buttonText: "Popup" }), @@ -149,7 +152,7 @@ test("change", function() { ok( image.length === 0, "Button - image absent" ); equal( button.text(), "Popup", "Button - button text" ); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.onFocus( inp, function() { ok( !dp.is( ":visible" ), "Button - not rendered on focus" ); button.click(); ok( dp.is( ":visible" ), "Button - rendered on button click" ); @@ -162,7 +165,7 @@ test("change", function() { } function step3() { - var inp = TestHelpers.datepicker.initNewInput({ + var inp = datepickerTestHelpers.initNewInput({ showOn: "button", buttonImageOnly: true, buttonImage: "images/calendar.gif", @@ -178,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" ); - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.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" ); @@ -191,7 +194,7 @@ test("change", function() { } function step4() { - var inp = TestHelpers.datepicker.initNewInput({ + var inp = datepickerTestHelpers.initNewInput({ showOn: "both", buttonImage: "images/calendar.gif" }), @@ -207,7 +210,7 @@ test("change", function() { // TODO: This test occasionally fails to focus in IE8 in BrowserStack if ( !isOldIE ) { - TestHelpers.datepicker.onFocus( inp, function() { + datepickerTestHelpers.onFocus( inp, function() { ok( dp.is( ":visible" ), "Both - rendered on focus" ); body.simulate( "mousedown", {} ); ok( !dp.is( ":visible" ), "Both - hidden on external click" ); @@ -230,7 +233,7 @@ test("change", function() { test("otherMonths", function() { expect( 8 ); - var inp = TestHelpers.datepicker.init("#inp"), + var inp = datepickerTestHelpers.init("#inp"), pop = $("#ui-datepicker-div"); inp.val("06/01/2009").datepicker("show"); equal(pop.find("tbody").text(), @@ -258,105 +261,105 @@ test("otherMonths", function() { test("defaultDate", function() { expect( 16 ); - var inp = TestHelpers.datepicker.init("#inp"), + var inp = datepickerTestHelpers.init("#inp"), date = new Date(); inp.val("").datepicker("show"). simulate("keydown", {keyCode: $.ui.keyCode.ENTER}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date null"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -2"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date 3"); + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date NaN"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -1d"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +3D"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -2 w"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +1 W"); + datepickerTestHelpers.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 = TestHelpers.datepicker.addMonths(new Date(), -1); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -1 m"); + date = datepickerTestHelpers.addMonths(new Date(), -1); + datepickerTestHelpers.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 = TestHelpers.datepicker.addMonths(new Date(), 2); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +2M"); + date = datepickerTestHelpers.addMonths(new Date(), 2); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date -2y"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +1 Y"); + datepickerTestHelpers.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 = TestHelpers.datepicker.addMonths(new Date(), 1); + date = datepickerTestHelpers.addMonths(new Date(), 1); date.setDate(date.getDate() + 10); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date +1M +10d"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date 07/04/2007"); + datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date 2007-04-02"); + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, "Default date 01/26/2007"); + datepickerTestHelpers.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 = TestHelpers.datepicker.init("#inp"); + inp = datepickerTestHelpers.init("#inp"); // Year range function genRange(start, offset) { var i = start, @@ -417,7 +420,7 @@ test("miscellaneous", function() { test("minMax", function() { expect( 23 ); var date, - inp = TestHelpers.datepicker.init("#inp"), + inp = datepickerTestHelpers.init("#inp"), dp = $("#ui-datepicker-div"), lastYear = new Date(2007, 6 - 1, 4), nextYear = new Date(2009, 6 - 1, 4), @@ -426,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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), lastYear, + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), nextYear, + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), nextYear, + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), lastYear, + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - null, 12/07/2008 - ctrl+pgdn"); // Relative dates date = new Date(); @@ -473,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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Min/max - -1w, +1 M +10 D - ctrl+pgup"); - date = TestHelpers.datepicker.addMonths(new Date(), 1); + date = datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date, + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date, "Min/max - -1w, +1 M +10 D - ctrl+pgdn"); // With existing date - inp = TestHelpers.datepicker.init("#inp"); + inp = datepickerTestHelpers.init("#inp"); inp.val("06/04/2008").datepicker("option", {minDate: minDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min"); + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); inp.datepicker("option", {minDate: null}).val("06/04/2008").datepicker("option", {maxDate: maxDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate < max"); + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); inp.datepicker("option", {maxDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min"); inp.datepicker("option", {maxDate: null}).val("06/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min, < max"); + datepickerTestHelpers.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}); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max"); + datepickerTestHelpers.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"); @@ -524,50 +527,50 @@ test("minMax", function() { test("setDate", function() { expect( 24 ); var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone, - inp = TestHelpers.datepicker.init("#inp"), + inp = datepickerTestHelpers.init("#inp"), date1 = new Date(2008, 6 - 1, 4), date2 = new Date(); ok(inp.datepicker("getDate") == null, "Set date - default"); inp.datepicker("setDate", date1); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - 2008-06-04"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - 2008-06-04"); date1 = new Date(); date1.setDate(date1.getDate() + 7); inp.datepicker("setDate", +7); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - +7"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - +7"); date2.setFullYear(date2.getFullYear() + 2); inp.datepicker("setDate", "+2y"); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date2, "Set date - +2y"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date2, "Set date - +2y"); inp.datepicker("setDate", date1, date2); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - two dates"); + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - c +7"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - c +7"); date1.setDate(date1.getDate() + 7); inp.datepicker("setDate", "c+7"); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - c+7"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - c+7"); date1.setDate(date1.getDate() - 21); inp.datepicker("setDate", "c -3 w"); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date - c -3 w"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date - c -3 w"); // Inline - inl = TestHelpers.datepicker.init("#inl"); + inl = datepickerTestHelpers.init("#inl"); date1 = new Date(2008, 6 - 1, 4); date2 = new Date(); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - default"); + datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - default"); inl.datepicker("setDate", date1); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - 2008-06-04"); + datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - 2008-06-04"); date1 = new Date(); date1.setDate(date1.getDate() + 7); inl.datepicker("setDate", +7); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - +7"); + datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - +7"); date2.setFullYear(date2.getFullYear() + 2); inl.datepicker("setDate", "+2y"); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - +2y"); + datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - +2y"); inl.datepicker("setDate", date1, date2); - TestHelpers.datepicker.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - two dates"); + datepickerTestHelpers.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - two dates"); inl.datepicker("setDate"); ok(inl.datepicker("getDate") == null, "Set date inline - null"); // Alternate field @@ -578,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 = TestHelpers.datepicker.init("#inp"); + inp = datepickerTestHelpers.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); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date2, "Set date min/max - setDate > min"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date2, "Set date min/max - setDate > min"); inp.datepicker("setDate", date1); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); inp.val("").datepicker("option", {maxDate: maxDate, minDate: null}).datepicker("setDate", date1); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), date1, "Set date min/max - setDate < max"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), date1, "Set date min/max - setDate < max"); inp.datepicker("setDate", date2); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date1); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); + datepickerTestHelpers.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min"); inp.datepicker("setDate", date2); - TestHelpers.datepicker.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max"); + datepickerTestHelpers.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); @@ -603,7 +606,7 @@ test("setDate", function() { test("altField", function() { expect( 10 ); - var inp = TestHelpers.datepicker.init("#inp"), + var inp = datepickerTestHelpers.init("#inp"), alt = $("#alt"); // No alternate field set alt.val(""); @@ -642,7 +645,7 @@ test("altField", function() { test("autoSize", function() { expect( 15 ); - var inp = TestHelpers.datepicker.init("#inp"); + var inp = datepickerTestHelpers.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"); @@ -680,7 +683,7 @@ test("autoSize", function() { test("daylightSaving", function() { expect( 25 ); - var inp = TestHelpers.datepicker.init("#inp"), + var inp = datepickerTestHelpers.init("#inp"), dp = $("#ui-datepicker-div"); ok(true, "Daylight saving - " + new Date()); // Australia, Sydney - AM change, southern hemisphere @@ -786,7 +789,7 @@ test("callbacks", function() { expect( 13 ); // Before show var dp, day20, day21, - inp = TestHelpers.datepicker.init("#inp", {beforeShow: beforeAll}), + inp = datepickerTestHelpers.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"); @@ -796,7 +799,7 @@ test("callbacks", function() { deepEqual(beforeShowInst, inst, "Before show - inst OK"); inp.datepicker("hide").datepicker("destroy"); // Before show day - inp = TestHelpers.datepicker.init("#inp", {beforeShowDay: beforeDay}); + inp = datepickerTestHelpers.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"); @@ -815,7 +818,7 @@ test("callbacks", function() { test("beforeShowDay - tooltips with quotes", function() { expect( 1 ); var inp, dp; - inp = TestHelpers.datepicker.init("#inp", { + inp = datepickerTestHelpers.init("#inp", { beforeShowDay: function() { return [ true, "", "'" ]; } @@ -830,7 +833,7 @@ test("beforeShowDay - tooltips with quotes", function() { test("localisation", function() { expect( 24 ); var dp, month, day, date, - inp = TestHelpers.datepicker.init("#inp", $.datepicker.regional.fr); + inp = datepickerTestHelpers.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"); @@ -897,72 +900,72 @@ test("iso8601Week", function() { test("parseDate", function() { expect( 26 ); - TestHelpers.datepicker.init("#inp"); + datepickerTestHelpers.init("#inp"); var currentYear, gmtDate, fr, settings, zh; ok($.datepicker.parseDate("d m y", "") == null, "Parse date empty"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("d m y", "3 2 01"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("d m y", "3 2 01"), new Date(2001, 2 - 1, 3), "Parse date d m y"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("dd mm yy", "03 02 2001"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("dd mm yy", "03 02 2001"), new Date(2001, 2 - 1, 3), "Parse date dd mm yy"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("d m y", "13 12 01"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("d m y", "13 12 01"), new Date(2001, 12 - 1, 13), "Parse date d m y"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("dd mm yy", "13 12 2001"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("dd mm yy", "13 12 2001"), new Date(2001, 12 - 1, 13), "Parse date dd mm yy"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-o", "01-34"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-o", "01-34"), new Date(2001, 2 - 1, 3), "Parse date y-o"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("yy-oo", "2001-347"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("yy-oo", "2001-347"), new Date(2001, 12 - 1, 13), "Parse date yy-oo"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("oo yy", "348 2004"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("oo yy", "348 2004"), new Date(2004, 12 - 1, 13), "Parse date oo yy"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("D d M y", "Sat 3 Feb 01"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("D d M y", "Sat 3 Feb 01"), new Date(2001, 2 - 1, 3), "Parse date D d M y"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("d MM DD yy", "3 February Saturday 2001"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("d MM DD yy", "3 February Saturday 2001"), new Date(2001, 2 - 1, 3), "Parse date dd MM DD yy"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Saturday, February 3, 2001"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Saturday, February 3, 2001"), new Date(2001, 2 - 1, 3), "Parse date DD, MM d, yy"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("'day' d 'of' MM (''DD''), yy", + datepickerTestHelpers.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(); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000) + "-02-03"), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000) + "-02-03"), new Date(currentYear, 2 - 1, 3), "Parse date y-m-d - default cutuff"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 10) + "-02-03"), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 11) + "-02-03"), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", "80-02-03", {shortYearCutoff: 80}), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", "80-02-03", {shortYearCutoff: 80}), new Date(2080, 2 - 1, 3), "Parse date y-m-d - cutoff 80"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", "81-02-03", {shortYearCutoff: 80}), + datepickerTestHelpers.equalsDate($.datepicker.parseDate("y-m-d", "81-02-03", {shortYearCutoff: 80}), new Date(1981, 2 - 1, 3), "Parse date y-m-d - cutoff 80"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 60) + "-02-03", {shortYearCutoff: "+60"}), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 61) + "-02-03", {shortYearCutoff: "+60"}), + datepickerTestHelpers.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()); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("@", "981158400000"), gmtDate, "Parse date @"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("!", "631167552000000000"), gmtDate, "Parse date !"); + datepickerTestHelpers.equalsDate($.datepicker.parseDate("@", "981158400000"), gmtDate, "Parse date @"); + datepickerTestHelpers.equalsDate($.datepicker.parseDate("!", "631167552000000000"), gmtDate, "Parse date !"); fr = $.datepicker.regional.fr; settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("D d M y", "Lun. 9 avr. 01", settings), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("d MM DD yy", "9 Avril Lundi 2001", settings), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Lundi, Avril 9, 2001", settings), + datepickerTestHelpers.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"); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings), + datepickerTestHelpers.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"]; - TestHelpers.datepicker.equalsDate($.datepicker.parseDate("yy M d", "2011 十一月 22", zh), + datepickerTestHelpers.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 ); - TestHelpers.datepicker.init("#inp"); + datepickerTestHelpers.init("#inp"); var fr, settings; function expectError(expr, value, error) { try { @@ -1037,7 +1040,7 @@ test("Ticket #7244: date parser does not fail when too many numbers are passed i test("formatDate", function() { expect( 16 ); - TestHelpers.datepicker.init("#inp"); + datepickerTestHelpers.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"); @@ -1090,7 +1093,7 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler var inp, dp; - inp = TestHelpers.datepicker.init( "#inp", { + inp = datepickerTestHelpers.init( "#inp", { beforeShow: function() { } }); @@ -1099,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 = TestHelpers.datepicker.init( "#inp", { + inp = datepickerTestHelpers.init( "#inp", { beforeShow: function() { return true; } @@ -1110,7 +1113,7 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler inp.datepicker( "hide" ); inp.datepicker( "destroy" ); - inp = TestHelpers.datepicker.init( "#inp", { + inp = datepickerTestHelpers.init( "#inp", { beforeShow: function() { return false; } @@ -1121,4 +1124,4 @@ test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler inp.datepicker( "destroy" ); }); -})(jQuery); +} ); diff --git a/tests/unit/datepicker/datepicker_test_helpers.js b/tests/unit/datepicker/datepicker_test_helpers.js index 82610393b..40dc93410 100644 --- a/tests/unit/datepicker/datepicker_test_helpers.js +++ b/tests/unit/datepicker/datepicker_test_helpers.js @@ -1,4 +1,9 @@ -TestHelpers.datepicker = { +define( [ + "lib/helper", + "ui/datepicker" +], function( testHelpers ) { + +var datepickerTestHelpers = { addMonths: function(date, offset) { var maxDay = 32 - new Date(date.getFullYear(), date.getMonth() + offset, 32).getDate(); date.setDate(Math.min(date.getDate(), maxDay)); @@ -20,8 +25,12 @@ TestHelpers.datepicker = { }, initNewInput: function( options ) { var id = $( "" ).appendTo( "#qunit-fixture" ); - return TestHelpers.datepicker.init( id, options ); + return datepickerTestHelpers.init( id, options ); }, - onFocus: TestHelpers.onFocus, + onFocus: testHelpers.onFocus, PROP_NAME: "datepicker" }; + +return datepickerTestHelpers; + +} ); -- cgit v1.2.3