2015-04-07 00:06:31 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
2015-04-07 14:55:52 +00:00
|
|
|
"./helper",
|
2015-04-07 00:06:31 +00:00
|
|
|
"ui/datepicker",
|
|
|
|
"ui/i18n/datepicker-fr",
|
|
|
|
"ui/i18n/datepicker-he",
|
|
|
|
"ui/i18n/datepicker-zh-CN"
|
2015-04-07 14:30:07 +00:00
|
|
|
], function( $, testHelper ) {
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2011-02-18 15:08:17 +00:00
|
|
|
module("datepicker: options");
|
2009-02-02 14:36:08 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("setDefaults", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 3 );
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.init("#inp");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker._defaults.showOn, "focus", "Initial showOn");
|
|
|
|
$.datepicker.setDefaults({showOn: "button"});
|
|
|
|
equal($.datepicker._defaults.showOn, "button", "Change default showOn");
|
|
|
|
$.datepicker.setDefaults({showOn: "focus"});
|
|
|
|
equal($.datepicker._defaults.showOn, "focus", "Restore showOn");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("option", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 17 );
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.init("#inp"),
|
|
|
|
inst = $.data(inp[0], testHelper.PROP_NAME);
|
2009-04-01 10:11:35 +00:00
|
|
|
// Set option
|
2012-12-26 13:08:48 +00:00
|
|
|
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");
|
|
|
|
inp.datepicker("option", "showOn", "button");
|
|
|
|
equal(inst.settings.showOn, "button", "Change setting showOn");
|
|
|
|
equal($.datepicker._get(inst, "showOn"), "button", "Change instance showOn");
|
|
|
|
equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
|
|
|
|
inp.datepicker("option", {showOn: "both"});
|
|
|
|
equal(inst.settings.showOn, "both", "Change setting showOn");
|
|
|
|
equal($.datepicker._get(inst, "showOn"), "both", "Change instance showOn");
|
|
|
|
equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
|
|
|
|
inp.datepicker("option", "showOn", undefined);
|
|
|
|
equal(inst.settings.showOn, null, "Clear setting showOn");
|
|
|
|
equal($.datepicker._get(inst, "showOn"), "focus", "Restore instance showOn");
|
|
|
|
equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
|
2009-04-01 10:11:35 +00:00
|
|
|
// Get option
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(inp.datepicker("option", "showOn"), "focus", "Initial setting showOn");
|
|
|
|
inp.datepicker("option", "showOn", "button");
|
|
|
|
equal(inp.datepicker("option", "showOn"), "button", "Change instance showOn");
|
|
|
|
inp.datepicker("option", "showOn", undefined);
|
|
|
|
equal(inp.datepicker("option", "showOn"), "focus", "Reset instance showOn");
|
|
|
|
deepEqual(inp.datepicker("option", "all"), {showAnim: ""}, "Get instance settings");
|
|
|
|
deepEqual(inp.datepicker("option", "defaults"), $.datepicker._defaults,
|
|
|
|
"Get default settings");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-05 15:38:31 +00:00
|
|
|
test( "disabled", function() {
|
|
|
|
expect(8);
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.init("#inp");
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(!inp.datepicker("isDisabled"), "Initially marked as enabled");
|
|
|
|
ok(!inp[0].disabled, "Field initially enabled");
|
|
|
|
inp.datepicker("option", "disabled", true);
|
|
|
|
ok(inp.datepicker("isDisabled"), "Marked as disabled");
|
|
|
|
ok(inp[0].disabled, "Field now disabled");
|
|
|
|
inp.datepicker("option", "disabled", false);
|
|
|
|
ok(!inp.datepicker("isDisabled"), "Marked as enabled");
|
|
|
|
ok(!inp[0].disabled, "Field now enabled");
|
|
|
|
inp.datepicker("destroy");
|
2012-12-05 15:38:31 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp", { disabled: true });
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(inp.datepicker("isDisabled"), "Initially marked as disabled");
|
|
|
|
ok(inp[0].disabled, "Field initially disabled");
|
2012-12-06 16:56:56 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("change", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 12 );
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.init("#inp"),
|
|
|
|
inst = $.data(inp[0], testHelper.PROP_NAME);
|
2012-12-26 13:08:48 +00:00
|
|
|
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");
|
|
|
|
inp.datepicker("change", "showOn", "button");
|
|
|
|
equal(inst.settings.showOn, "button", "Change setting showOn");
|
|
|
|
equal($.datepicker._get(inst, "showOn"), "button", "Change instance showOn");
|
|
|
|
equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
|
|
|
|
inp.datepicker("change", {showOn: "both"});
|
|
|
|
equal(inst.settings.showOn, "both", "Change setting showOn");
|
|
|
|
equal($.datepicker._get(inst, "showOn"), "both", "Change instance showOn");
|
|
|
|
equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
|
|
|
|
inp.datepicker("change", "showOn", undefined);
|
|
|
|
equal(inst.settings.showOn, null, "Clear setting showOn");
|
|
|
|
equal($.datepicker._get(inst, "showOn"), "focus", "Restore instance showOn");
|
|
|
|
equal($.datepicker._defaults.showOn, "focus", "Retain default showOn");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2013-12-03 16:52:11 +00:00
|
|
|
(function() {
|
|
|
|
var url = window.location.search;
|
|
|
|
url = decodeURIComponent( url.slice( url.indexOf( "swarmURL=" ) + 9 ) );
|
|
|
|
|
|
|
|
// TODO: This test occassionally fails in IE in TestSwarm
|
|
|
|
if ( $.ui.ie && url && url.indexOf( "http" ) === 0 ) {
|
|
|
|
return;
|
2013-04-12 00:48:05 +00:00
|
|
|
}
|
2013-04-07 18:16:31 +00:00
|
|
|
|
2013-12-03 16:52:11 +00:00
|
|
|
asyncTest( "invocation", function() {
|
|
|
|
var button, image,
|
|
|
|
isOldIE = $.ui.ie && ( !document.documentMode || document.documentMode < 9 ),
|
|
|
|
body = $( "body" );
|
2013-04-07 18:16:31 +00:00
|
|
|
|
2013-12-03 16:52:11 +00:00
|
|
|
expect( isOldIE ? 25 : 29 );
|
2013-04-12 00:48:05 +00:00
|
|
|
|
2013-12-03 16:52:11 +00:00
|
|
|
function step0() {
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.initNewInput(),
|
2013-12-03 16:52:11 +00:00
|
|
|
dp = $( "#ui-datepicker-div" );
|
2013-04-12 00:48:05 +00:00
|
|
|
|
2013-12-03 16:52:11 +00:00
|
|
|
button = inp.siblings( "button" );
|
|
|
|
ok( button.length === 0, "Focus - button absent" );
|
|
|
|
image = inp.siblings( "img" );
|
|
|
|
ok( image.length === 0, "Focus - image absent" );
|
2012-12-11 15:06:13 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2013-12-03 16:52:11 +00:00
|
|
|
ok( dp.is( ":visible" ), "Focus - rendered on focus" );
|
|
|
|
inp.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
|
|
|
ok( !dp.is( ":visible" ), "Focus - hidden on exit" );
|
|
|
|
step1();
|
|
|
|
});
|
|
|
|
}
|
2012-12-11 15:06:13 +00:00
|
|
|
|
2013-12-03 16:52:11 +00:00
|
|
|
function step1() {
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.initNewInput(),
|
2013-12-03 16:52:11 +00:00
|
|
|
dp = $( "#ui-datepicker-div" );
|
2012-12-11 15:06:13 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2013-12-03 16:52:11 +00:00
|
|
|
ok( dp.is( ":visible" ), "Focus - rendered on focus" );
|
2013-04-12 00:48:05 +00:00
|
|
|
body.simulate( "mousedown", {} );
|
2013-12-03 16:52:11 +00:00
|
|
|
ok( !dp.is( ":visible" ), "Focus - hidden on external click" );
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
|
|
|
|
|
|
|
step2();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function step2() {
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.initNewInput({
|
2013-12-03 16:52:11 +00:00
|
|
|
showOn: "button",
|
|
|
|
buttonText: "Popup"
|
|
|
|
}),
|
|
|
|
dp = $( "#ui-datepicker-div" );
|
|
|
|
|
|
|
|
ok( !dp.is( ":visible" ), "Button - initially hidden" );
|
|
|
|
button = inp.siblings( "button" );
|
|
|
|
image = inp.siblings( "img" );
|
|
|
|
ok( button.length === 1, "Button - button present" );
|
|
|
|
ok( image.length === 0, "Button - image absent" );
|
|
|
|
equal( button.text(), "Popup", "Button - button text" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2013-12-03 16:52:11 +00:00
|
|
|
ok( !dp.is( ":visible" ), "Button - not rendered on focus" );
|
2013-04-12 00:48:05 +00:00
|
|
|
button.click();
|
2013-12-03 16:52:11 +00:00
|
|
|
ok( dp.is( ":visible" ), "Button - rendered on button click" );
|
2013-04-12 00:48:05 +00:00
|
|
|
button.click();
|
2013-12-03 16:52:11 +00:00
|
|
|
ok( !dp.is( ":visible" ), "Button - hidden on second button click" );
|
2013-04-12 00:48:05 +00:00
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
2013-04-07 18:16:31 +00:00
|
|
|
|
2013-12-03 16:52:11 +00:00
|
|
|
step3();
|
2013-04-12 00:48:05 +00:00
|
|
|
});
|
|
|
|
}
|
2012-12-11 15:06:13 +00:00
|
|
|
|
2013-12-03 16:52:11 +00:00
|
|
|
function step3() {
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.initNewInput({
|
2013-12-03 16:52:11 +00:00
|
|
|
showOn: "button",
|
|
|
|
buttonImageOnly: true,
|
|
|
|
buttonImage: "images/calendar.gif",
|
|
|
|
buttonText: "Cal"
|
|
|
|
}),
|
|
|
|
dp = $( "#ui-datepicker-div" );
|
|
|
|
|
|
|
|
ok( !dp.is( ":visible" ), "Image button - initially hidden" );
|
|
|
|
button = inp.siblings( "button" );
|
|
|
|
ok( button.length === 0, "Image button - button absent" );
|
|
|
|
image = inp.siblings( "img" );
|
|
|
|
ok( image.length === 1, "Image button - image present" );
|
|
|
|
ok( /images\/calendar\.gif$/.test( image.attr( "src" ) ), "Image button - image source" );
|
|
|
|
equal( image.attr( "title" ), "Cal", "Image button - image text" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2013-12-03 16:52:11 +00:00
|
|
|
ok( !dp.is( ":visible" ), "Image button - not rendered on focus" );
|
|
|
|
image.click();
|
|
|
|
ok( dp.is( ":visible" ), "Image button - rendered on image click" );
|
|
|
|
image.click();
|
|
|
|
ok( !dp.is( ":visible" ), "Image button - hidden on second image click" );
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
|
|
|
|
|
|
|
step4();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function step4() {
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.initNewInput({
|
2013-12-03 16:52:11 +00:00
|
|
|
showOn: "both",
|
|
|
|
buttonImage: "images/calendar.gif"
|
|
|
|
}),
|
|
|
|
dp = $( "#ui-datepicker-div" );
|
|
|
|
|
|
|
|
ok( !dp.is( ":visible" ), "Both - initially hidden" );
|
|
|
|
button = inp.siblings( "button" );
|
|
|
|
ok( button.length === 1, "Both - button present" );
|
|
|
|
image = inp.siblings( "img" );
|
|
|
|
ok( image.length === 0, "Both - image absent" );
|
|
|
|
image = button.children( "img" );
|
|
|
|
ok( image.length === 1, "Both - button image present" );
|
|
|
|
|
|
|
|
// TODO: This test occasionally fails to focus in IE8 in BrowserStack
|
|
|
|
if ( !isOldIE ) {
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.onFocus( inp, function() {
|
2013-12-03 16:52:11 +00:00
|
|
|
ok( dp.is( ":visible" ), "Both - rendered on focus" );
|
|
|
|
body.simulate( "mousedown", {} );
|
|
|
|
ok( !dp.is( ":visible" ), "Both - hidden on external click" );
|
|
|
|
button.click();
|
|
|
|
ok( dp.is( ":visible" ), "Both - rendered on button click" );
|
|
|
|
button.click();
|
|
|
|
ok( !dp.is( ":visible" ), "Both - hidden on second button click" );
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
|
|
|
|
|
|
|
start();
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
step0();
|
|
|
|
});
|
|
|
|
})();
|
2009-02-04 04:27:14 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("otherMonths", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 8 );
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.init("#inp"),
|
2012-12-26 13:08:48 +00:00
|
|
|
pop = $("#ui-datepicker-div");
|
|
|
|
inp.val("06/01/2009").datepicker("show");
|
|
|
|
equal(pop.find("tbody").text(),
|
2012-11-15 23:57:44 +00:00
|
|
|
// support: IE <9, jQuery <1.8
|
|
|
|
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
|
|
|
|
$( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(),
|
2012-12-26 13:08:48 +00:00
|
|
|
"Other months - none");
|
|
|
|
ok(pop.find("td:last *").length === 0, "Other months - no content");
|
|
|
|
inp.datepicker("hide").datepicker("option", "showOtherMonths", true).datepicker("show");
|
|
|
|
equal(pop.find("tbody").text(), "311234567891011121314151617181920212223242526272829301234",
|
|
|
|
"Other months - show");
|
|
|
|
ok(pop.find("td:last span").length === 1, "Other months - span content");
|
|
|
|
inp.datepicker("hide").datepicker("option", "selectOtherMonths", true).datepicker("show");
|
|
|
|
equal(pop.find("tbody").text(), "311234567891011121314151617181920212223242526272829301234",
|
|
|
|
"Other months - select");
|
|
|
|
ok(pop.find("td:last a").length === 1, "Other months - link content");
|
|
|
|
inp.datepicker("hide").datepicker("option", "showOtherMonths", false).datepicker("show");
|
|
|
|
equal(pop.find("tbody").text(),
|
2012-11-15 23:57:44 +00:00
|
|
|
// support: IE <9, jQuery <1.8
|
|
|
|
// In IE7/8 with jQuery <1.8, encoded spaces behave in strange ways
|
|
|
|
$( "<span>\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0</span>" ).text(),
|
2012-12-26 13:08:48 +00:00
|
|
|
"Other months - none");
|
|
|
|
ok(pop.find("td:last *").length === 0, "Other months - no content");
|
2009-06-21 07:28:51 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("defaultDate", function() {
|
2012-11-09 22:06:30 +00:00
|
|
|
expect( 16 );
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.init("#inp"),
|
2012-04-19 15:17:35 +00:00
|
|
|
date = new Date();
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date null");
|
2012-11-09 22:06:30 +00:00
|
|
|
|
2009-06-16 08:44:56 +00:00
|
|
|
// Numeric values
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: -2}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-02-04 04:27:14 +00:00
|
|
|
date.setDate(date.getDate() - 2);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2");
|
2012-11-09 22:06:30 +00:00
|
|
|
|
|
|
|
date = new Date();
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: 3}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2012-11-09 22:06:30 +00:00
|
|
|
date.setDate(date.getDate() + 3);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 3");
|
2012-11-09 22:06:30 +00:00
|
|
|
|
|
|
|
date = new Date();
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: 1 / "a"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date NaN");
|
2012-11-09 22:06:30 +00:00
|
|
|
|
2009-06-16 08:44:56 +00:00
|
|
|
// String offset values
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: "-1d"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-02-04 04:27:14 +00:00
|
|
|
date.setDate(date.getDate() - 1);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -1d");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: "+3D"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-02-04 04:27:14 +00:00
|
|
|
date.setDate(date.getDate() + 4);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +3D");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: " -2 w "}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date();
|
|
|
|
date.setDate(date.getDate() - 14);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2 w");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: "+1 W"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-02-04 04:27:14 +00:00
|
|
|
date.setDate(date.getDate() + 21);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1 W");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: " -1 m "}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
date = testHelper.addMonths(new Date(), -1);
|
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -1 m");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: "+2M"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
date = testHelper.addMonths(new Date(), 2);
|
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +2M");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: "-2y"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date();
|
|
|
|
date.setFullYear(date.getFullYear() - 2);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date -2y");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: "+1 Y "}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-02-04 04:27:14 +00:00
|
|
|
date.setFullYear(date.getFullYear() + 3);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1 Y");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: "+1M +10d"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
date = testHelper.addMonths(new Date(), 1);
|
2009-02-04 04:27:14 +00:00
|
|
|
date.setDate(date.getDate() + 10);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date +1M +10d");
|
2009-06-16 08:44:56 +00:00
|
|
|
// String date values
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {defaultDate: "07/04/2007"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-06-16 08:44:56 +00:00
|
|
|
date = new Date(2007, 7 - 1, 4);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 07/04/2007");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {dateFormat: "yy-mm-dd", defaultDate: "2007-04-02"}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2009-06-16 08:44:56 +00:00
|
|
|
date = new Date(2007, 4 - 1, 2);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 2007-04-02");
|
2009-06-16 08:44:56 +00:00
|
|
|
// Date value
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2007, 1 - 1, 26);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {dateFormat: "mm/dd/yy", defaultDate: date}).
|
|
|
|
datepicker("hide").val("").datepicker("show").
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date, "Default date 01/26/2007");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("miscellaneous", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 19 );
|
2012-04-19 15:17:35 +00:00
|
|
|
var curYear, longNames, shortNames, date,
|
2012-12-26 13:08:48 +00:00
|
|
|
dp = $("#ui-datepicker-div"),
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Year range
|
2012-04-19 15:17:35 +00:00
|
|
|
function genRange(start, offset) {
|
|
|
|
var i = start,
|
2012-12-26 13:08:48 +00:00
|
|
|
range = "";
|
2012-04-19 15:17:35 +00:00
|
|
|
for (; i < start + offset; i++) {
|
2009-02-04 04:27:14 +00:00
|
|
|
range += i;
|
|
|
|
}
|
|
|
|
return range;
|
2012-04-19 15:17:35 +00:00
|
|
|
}
|
|
|
|
curYear = new Date().getFullYear();
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("02/04/2008").datepicker("show");
|
|
|
|
equal(dp.find(".ui-datepicker-year").text(), "2008", "Year range - read-only default");
|
|
|
|
inp.datepicker("hide").datepicker("option", {changeYear: true}).datepicker("show");
|
|
|
|
equal(dp.find(".ui-datepicker-year").text(), genRange(2008 - 10, 21), "Year range - changeable default");
|
|
|
|
inp.datepicker("hide").datepicker("option", {yearRange: "c-6:c+2", changeYear: true}).datepicker("show");
|
|
|
|
equal(dp.find(".ui-datepicker-year").text(), genRange(2008 - 6, 9), "Year range - c-6:c+2");
|
|
|
|
inp.datepicker("hide").datepicker("option", {yearRange: "2000:2010", changeYear: true}).datepicker("show");
|
|
|
|
equal(dp.find(".ui-datepicker-year").text(), genRange(2000, 11), "Year range - 2000:2010");
|
|
|
|
inp.datepicker("hide").datepicker("option", {yearRange: "-5:+3", changeYear: true}).datepicker("show");
|
|
|
|
equal(dp.find(".ui-datepicker-year").text(), genRange(curYear - 5, 9), "Year range - -5:+3");
|
|
|
|
inp.datepicker("hide").datepicker("option", {yearRange: "2000:-5", changeYear: true}).datepicker("show");
|
|
|
|
equal(dp.find(".ui-datepicker-year").text(), genRange(2000, curYear - 2004), "Year range - 2000:-5");
|
|
|
|
inp.datepicker("hide").datepicker("option", {yearRange: "", changeYear: true}).datepicker("show");
|
|
|
|
equal(dp.find(".ui-datepicker-year").text(), genRange(curYear, 1), "Year range - -6:+2");
|
2009-02-04 04:27:14 +00:00
|
|
|
|
|
|
|
// Navigation as date format
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {showButtonPanel: true});
|
|
|
|
equal(dp.find(".ui-datepicker-prev").text(), "Prev", "Navigation prev - default");
|
|
|
|
equal(dp.find(".ui-datepicker-current").text(), "Today", "Navigation current - default");
|
|
|
|
equal(dp.find(".ui-datepicker-next").text(), "Next", "Navigation next - default");
|
|
|
|
inp.datepicker("hide").datepicker("option", {navigationAsDateFormat: true, prevText: "< M", currentText: "MM", nextText: "M >"}).
|
|
|
|
val("02/04/2008").datepicker("show");
|
|
|
|
longNames = $.datepicker.regional[""].monthNames;
|
|
|
|
shortNames = $.datepicker.regional[""].monthNamesShort;
|
2012-04-19 15:17:35 +00:00
|
|
|
date = new Date();
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(dp.find(".ui-datepicker-prev").text(), "< " + shortNames[0], "Navigation prev - as date format");
|
|
|
|
equal(dp.find(".ui-datepicker-current").text(),
|
|
|
|
longNames[date.getMonth()], "Navigation current - as date format");
|
|
|
|
equal(dp.find(".ui-datepicker-next").text(),
|
|
|
|
shortNames[2] + " >", "Navigation next - as date format");
|
|
|
|
inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN});
|
|
|
|
equal(dp.find(".ui-datepicker-prev").text(),
|
|
|
|
"< " + shortNames[1], "Navigation prev - as date format + pgdn");
|
|
|
|
equal(dp.find(".ui-datepicker-current").text(),
|
|
|
|
longNames[date.getMonth()], "Navigation current - as date format + pgdn");
|
|
|
|
equal(dp.find(".ui-datepicker-next").text(),
|
|
|
|
shortNames[3] + " >", "Navigation next - as date format + pgdn");
|
|
|
|
inp.datepicker("hide").datepicker("option", {gotoCurrent: true}).
|
|
|
|
val("02/04/2008").datepicker("show");
|
|
|
|
equal(dp.find(".ui-datepicker-prev").text(),
|
|
|
|
"< " + shortNames[0], "Navigation prev - as date format + goto current");
|
|
|
|
equal(dp.find(".ui-datepicker-current").text(),
|
|
|
|
longNames[1], "Navigation current - as date format + goto current");
|
|
|
|
equal(dp.find(".ui-datepicker-next").text(),
|
|
|
|
shortNames[2] + " >", "Navigation next - as date format + goto current");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("minMax", function() {
|
2013-01-23 19:41:01 +00:00
|
|
|
expect( 23 );
|
2012-04-19 15:17:35 +00:00
|
|
|
var date,
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp"),
|
2012-12-26 13:08:48 +00:00
|
|
|
dp = $("#ui-datepicker-div"),
|
2012-04-19 15:17:35 +00:00
|
|
|
lastYear = new Date(2007, 6 - 1, 4),
|
|
|
|
nextYear = new Date(2009, 6 - 1, 4),
|
|
|
|
minDate = new Date(2008, 2 - 1, 29),
|
|
|
|
maxDate = new Date(2008, 12 - 1, 7);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("06/04/2008").datepicker("show");
|
|
|
|
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), lastYear,
|
2012-12-26 13:08:48 +00:00
|
|
|
"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});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), nextYear,
|
2012-12-26 13:08:48 +00:00
|
|
|
"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});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), minDate,
|
2012-12-26 13:08:48 +00:00
|
|
|
"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});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), nextYear,
|
2012-12-26 13:08:48 +00:00
|
|
|
"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});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), minDate,
|
2012-12-26 13:08:48 +00:00
|
|
|
"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});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), maxDate,
|
2012-12-26 13:08:48 +00:00
|
|
|
"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});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), lastYear,
|
2012-12-26 13:08:48 +00:00
|
|
|
"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});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), maxDate,
|
2012-12-26 13:08:48 +00:00
|
|
|
"Min/max - null, 12/07/2008 - ctrl+pgdn");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Relative dates
|
2012-04-19 15:17:35 +00:00
|
|
|
date = new Date();
|
2009-02-04 04:27:14 +00:00
|
|
|
date.setDate(date.getDate() - 7);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {minDate: "-1w", maxDate: "+1 M +10 D "}).
|
|
|
|
datepicker("hide").val("").datepicker("show");
|
|
|
|
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}).
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date,
|
2012-12-26 13:08:48 +00:00
|
|
|
"Min/max - -1w, +1 M +10 D - ctrl+pgup");
|
2015-04-07 14:30:07 +00:00
|
|
|
date = testHelper.addMonths(new Date(), 1);
|
2009-02-04 04:27:14 +00:00
|
|
|
date.setDate(date.getDate() + 10);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("").datepicker("show");
|
|
|
|
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_DOWN}).
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date,
|
2012-12-26 13:08:48 +00:00
|
|
|
"Min/max - -1w, +1 M +10 D - ctrl+pgdn");
|
2009-04-10 08:22:47 +00:00
|
|
|
// With existing date
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("06/04/2008").datepicker("option", {minDate: minDate});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {minDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {minDate: null}).val("06/04/2008").datepicker("option", {maxDate: maxDate});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate < max");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {maxDate: null}).val("01/04/2009").datepicker("option", {maxDate: maxDate});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {maxDate: null}).val("01/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Min/max - setDate < min");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {maxDate: null}).val("06/04/2008").datepicker("option", {minDate: minDate, maxDate: maxDate});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), new Date(2008, 6 - 1, 4), "Min/max - setDate > min, < max");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {maxDate: null}).val("01/04/2009").datepicker("option", {minDate: minDate, maxDate: maxDate});
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Min/max - setDate > max");
|
2012-11-14 02:07:48 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", {yearRange: "-0:+1"}).val("01/01/" + new Date().getFullYear());
|
2012-11-14 02:07:48 +00:00
|
|
|
ok(dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - previous button disabled at 1/1/minYear");
|
|
|
|
inp.datepicker("setDate", "12/30/" + new Date().getFullYear());
|
|
|
|
ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - next button disabled at 12/30/maxYear");
|
2013-01-23 19:41:01 +00:00
|
|
|
|
|
|
|
inp.datepicker("option", {
|
|
|
|
minDate: new Date(1900, 0, 1),
|
2015-01-10 21:11:14 +00:00
|
|
|
maxDate: "-7Y",
|
|
|
|
yearRange: "1900:-7"
|
2013-01-23 19:41:01 +00:00
|
|
|
}).val( "" );
|
2015-01-10 21:09:18 +00:00
|
|
|
ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - relative - next button disabled");
|
|
|
|
ok(!dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - relative - prev button enabled");
|
2013-01-23 19:41:01 +00:00
|
|
|
|
|
|
|
inp.datepicker("option", {
|
|
|
|
minDate: new Date(1900, 0, 1),
|
|
|
|
maxDate: "1/25/2007",
|
|
|
|
yearRange: "1900:2007"
|
|
|
|
}).val( "" );
|
2015-01-10 21:09:18 +00:00
|
|
|
ok(dp.find(".ui-datepicker-next").hasClass("ui-state-disabled"), "Year Range Test - absolute - next button disabled");
|
|
|
|
ok(!dp.find(".ui-datepicker-prev").hasClass("ui-state-disabled"), "Year Range Test - absolute - prev button enabled");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("setDate", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 24 );
|
2012-04-19 15:17:35 +00:00
|
|
|
var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone,
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp"),
|
2012-04-19 15:17:35 +00:00
|
|
|
date1 = new Date(2008, 6 - 1, 4),
|
|
|
|
date2 = new Date();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(inp.datepicker("getDate") == null, "Set date - default");
|
|
|
|
inp.datepicker("setDate", date1);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - 2008-06-04");
|
2009-02-04 04:27:14 +00:00
|
|
|
date1 = new Date();
|
|
|
|
date1.setDate(date1.getDate() + 7);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", +7);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - +7");
|
2009-02-04 04:27:14 +00:00
|
|
|
date2.setFullYear(date2.getFullYear() + 2);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", "+2y");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date2, "Set date - +2y");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", date1, date2);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - two dates");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate");
|
|
|
|
ok(inp.datepicker("getDate") == null, "Set date - null");
|
2009-07-22 08:28:01 +00:00
|
|
|
// Relative to current date
|
|
|
|
date1 = new Date();
|
|
|
|
date1.setDate(date1.getDate() + 7);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", "c +7");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c +7");
|
2009-07-22 08:28:01 +00:00
|
|
|
date1.setDate(date1.getDate() + 7);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", "c+7");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c+7");
|
2009-07-22 08:28:01 +00:00
|
|
|
date1.setDate(date1.getDate() - 21);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", "c -3 w");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date - c -3 w");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Inline
|
2015-04-07 14:30:07 +00:00
|
|
|
inl = testHelper.init("#inl");
|
2009-02-04 04:27:14 +00:00
|
|
|
date1 = new Date(2008, 6 - 1, 4);
|
|
|
|
date2 = new Date();
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - default");
|
2012-12-26 13:08:48 +00:00
|
|
|
inl.datepicker("setDate", date1);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - 2008-06-04");
|
2009-02-04 04:27:14 +00:00
|
|
|
date1 = new Date();
|
|
|
|
date1.setDate(date1.getDate() + 7);
|
2012-12-26 13:08:48 +00:00
|
|
|
inl.datepicker("setDate", +7);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - +7");
|
2009-02-04 04:27:14 +00:00
|
|
|
date2.setFullYear(date2.getFullYear() + 2);
|
2012-12-26 13:08:48 +00:00
|
|
|
inl.datepicker("setDate", "+2y");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inl.datepicker("getDate"), date2, "Set date inline - +2y");
|
2012-12-26 13:08:48 +00:00
|
|
|
inl.datepicker("setDate", date1, date2);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inl.datepicker("getDate"), date1, "Set date inline - two dates");
|
2012-12-26 13:08:48 +00:00
|
|
|
inl.datepicker("setDate");
|
|
|
|
ok(inl.datepicker("getDate") == null, "Set date inline - null");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Alternate field
|
2012-12-26 13:08:48 +00:00
|
|
|
alt = $("#alt");
|
|
|
|
inp.datepicker("option", {altField: "#alt", altFormat: "yy-mm-dd"});
|
2009-02-04 04:27:14 +00:00
|
|
|
date1 = new Date(2008, 6 - 1, 4);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", date1);
|
|
|
|
equal(inp.val(), "06/04/2008", "Set date alternate - 06/04/2008");
|
|
|
|
equal(alt.val(), "2008-06-04", "Set date alternate - 2008-06-04");
|
2009-04-10 08:22:47 +00:00
|
|
|
// With minimum/maximum
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp");
|
2009-04-10 08:22:47 +00:00
|
|
|
date1 = new Date(2008, 1 - 1, 4);
|
|
|
|
date2 = new Date(2008, 6 - 1, 4);
|
2012-04-19 15:17:35 +00:00
|
|
|
minDate = new Date(2008, 2 - 1, 29);
|
|
|
|
maxDate = new Date(2008, 3 - 1, 28);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date2);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date2, "Set date min/max - setDate > min");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", date1);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("").datepicker("option", {maxDate: maxDate, minDate: null}).datepicker("setDate", date1);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), date1, "Set date min/max - setDate < max");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", date2);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("").datepicker("option", {minDate: minDate}).datepicker("setDate", date1);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), minDate, "Set date min/max - setDate < min");
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", date2);
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate(inp.datepicker("getDate"), maxDate, "Set date min/max - setDate > max");
|
2012-04-19 15:17:35 +00:00
|
|
|
dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0);
|
|
|
|
dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0);
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("setDate", dateAndTimeToSet);
|
|
|
|
equal(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), "Date object passed should not be changed by setDate");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("altField", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 10 );
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.init("#inp"),
|
2012-12-26 13:08:48 +00:00
|
|
|
alt = $("#alt");
|
2009-02-04 04:27:14 +00:00
|
|
|
// No alternate field set
|
2012-12-26 13:08:48 +00:00
|
|
|
alt.val("");
|
|
|
|
inp.val("06/04/2008").datepicker("show");
|
|
|
|
inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
|
|
|
equal(inp.val(), "06/04/2008", "Alt field - dp - enter");
|
|
|
|
equal(alt.val(), "", "Alt field - alt not set");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Alternate field set
|
2012-12-26 13:08:48 +00:00
|
|
|
alt.val("");
|
|
|
|
inp.datepicker("option", {altField: "#alt", altFormat: "yy-mm-dd"}).
|
|
|
|
val("06/04/2008").datepicker("show");
|
|
|
|
inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
|
|
|
equal(inp.val(), "06/04/2008", "Alt field - dp - enter");
|
|
|
|
equal(alt.val(), "2008-06-04", "Alt field - alt - enter");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Move from initial date
|
2012-12-26 13:08:48 +00:00
|
|
|
alt.val("");
|
|
|
|
inp.val("06/04/2008").datepicker("show");
|
|
|
|
inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
|
|
|
equal(inp.val(), "07/04/2008", "Alt field - dp - pgdn");
|
|
|
|
equal(alt.val(), "2008-07-04", "Alt field - alt - pgdn");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Alternate field set - closed
|
2012-12-26 13:08:48 +00:00
|
|
|
alt.val("");
|
|
|
|
inp.val("06/04/2008").datepicker("show");
|
|
|
|
inp.simulate("keydown", {keyCode: $.ui.keyCode.PAGE_DOWN}).
|
|
|
|
simulate("keydown", {keyCode: $.ui.keyCode.ESCAPE});
|
|
|
|
equal(inp.val(), "06/04/2008", "Alt field - dp - pgdn/esc");
|
|
|
|
equal(alt.val(), "", "Alt field - alt - pgdn/esc");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Clear date and alternate
|
2012-12-26 13:08:48 +00:00
|
|
|
alt.val("");
|
|
|
|
inp.val("06/04/2008").datepicker("show");
|
|
|
|
inp.simulate("keydown", {ctrlKey: true, keyCode: $.ui.keyCode.END});
|
|
|
|
equal(inp.val(), "", "Alt field - dp - ctrl+end");
|
|
|
|
equal(alt.val(), "", "Alt field - alt - ctrl+end");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("autoSize", function() {
|
2012-12-12 08:16:33 +00:00
|
|
|
expect( 15 );
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.init("#inp");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(inp.prop("size"), 20, "Auto size - default");
|
|
|
|
inp.datepicker("option", "autoSize", true);
|
|
|
|
equal(inp.prop("size"), 10, "Auto size - mm/dd/yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "m/d/yy");
|
|
|
|
equal(inp.prop("size"), 10, "Auto size - m/d/yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "D M d yy");
|
|
|
|
equal(inp.prop("size"), 15, "Auto size - D M d yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "DD, MM dd, yy");
|
|
|
|
equal(inp.prop("size"), 29, "Auto size - DD, MM dd, yy");
|
2012-11-09 22:06:30 +00:00
|
|
|
|
2009-07-22 08:37:28 +00:00
|
|
|
// French
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", $.extend({autoSize: false}, $.datepicker.regional.fr));
|
|
|
|
equal(inp.prop("size"), 29, "Auto size - fr - default");
|
|
|
|
inp.datepicker("option", "autoSize", true);
|
|
|
|
equal(inp.prop("size"), 10, "Auto size - fr - dd/mm/yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "m/d/yy");
|
|
|
|
equal(inp.prop("size"), 10, "Auto size - fr - m/d/yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "D M d yy");
|
|
|
|
equal(inp.prop("size"), 18, "Auto size - fr - D M d yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "DD, MM dd, yy");
|
|
|
|
equal(inp.prop("size"), 28, "Auto size - fr - DD, MM dd, yy");
|
2012-11-09 22:06:30 +00:00
|
|
|
|
2009-07-22 08:37:28 +00:00
|
|
|
// Hebrew
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("option", $.extend({autoSize: false}, $.datepicker.regional.he));
|
|
|
|
equal(inp.prop("size"), 28, "Auto size - he - default");
|
|
|
|
inp.datepicker("option", "autoSize", true);
|
|
|
|
equal(inp.prop("size"), 10, "Auto size - he - dd/mm/yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "m/d/yy");
|
|
|
|
equal(inp.prop("size"), 10, "Auto size - he - m/d/yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "D M d yy");
|
|
|
|
equal(inp.prop("size"), 16, "Auto size - he - D M d yy");
|
|
|
|
inp.datepicker("option", "dateFormat", "DD, MM dd, yy");
|
|
|
|
equal(inp.prop("size"), 23, "Auto size - he - DD, MM dd, yy");
|
2009-07-22 08:37:28 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("daylightSaving", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 25 );
|
2015-04-07 14:30:07 +00:00
|
|
|
var inp = testHelper.init("#inp"),
|
2012-12-26 13:08:48 +00:00
|
|
|
dp = $("#ui-datepicker-div");
|
|
|
|
ok(true, "Daylight saving - " + new Date());
|
2009-02-04 04:27:14 +00:00
|
|
|
// Australia, Sydney - AM change, southern hemisphere
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("04/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "04/05/2008", "Daylight saving - Australia 04/05/2008");
|
|
|
|
inp.val("04/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "04/06/2008", "Daylight saving - Australia 04/06/2008");
|
|
|
|
inp.val("04/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "04/07/2008", "Daylight saving - Australia 04/07/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/04/2008", "Daylight saving - Australia 10/04/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/05/2008", "Daylight saving - Australia 10/05/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/06/2008", "Daylight saving - Australia 10/06/2008");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Brasil, Brasilia - midnight change, southern hemisphere
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("02/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(20) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "02/16/2008", "Daylight saving - Brasil 02/16/2008");
|
|
|
|
inp.val("02/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(21) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "02/17/2008", "Daylight saving - Brasil 02/17/2008");
|
|
|
|
inp.val("02/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(22) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "02/18/2008", "Daylight saving - Brasil 02/18/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(13) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/11/2008", "Daylight saving - Brasil 10/11/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(14) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/12/2008", "Daylight saving - Brasil 10/12/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(15) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/13/2008", "Daylight saving - Brasil 10/13/2008");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Lebanon, Beirut - midnight change, northern hemisphere
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("03/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(34) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "03/29/2008", "Daylight saving - Lebanon 03/29/2008");
|
|
|
|
inp.val("03/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(35) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "03/30/2008", "Daylight saving - Lebanon 03/30/2008");
|
|
|
|
inp.val("03/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(36) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "03/31/2008", "Daylight saving - Lebanon 03/31/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(27) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/25/2008", "Daylight saving - Lebanon 10/25/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(28) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/26/2008", "Daylight saving - Lebanon 10/26/2008");
|
|
|
|
inp.val("10/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(29) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "10/27/2008", "Daylight saving - Lebanon 10/27/2008");
|
2009-02-04 04:27:14 +00:00
|
|
|
// US, Eastern - AM change, northern hemisphere
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.val("03/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(13) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "03/08/2008", "Daylight saving - US 03/08/2008");
|
|
|
|
inp.val("03/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(14) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "03/09/2008", "Daylight saving - US 03/09/2008");
|
|
|
|
inp.val("03/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(15) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "03/10/2008", "Daylight saving - US 03/10/2008");
|
|
|
|
inp.val("11/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(6) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "11/01/2008", "Daylight saving - US 11/01/2008");
|
|
|
|
inp.val("11/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(7) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "11/02/2008", "Daylight saving - US 11/02/2008");
|
|
|
|
inp.val("11/01/2008").datepicker("show");
|
|
|
|
$(".ui-datepicker-calendar td:eq(8) a", dp).simulate("click");
|
|
|
|
equal(inp.val(), "11/03/2008", "Daylight saving - US 11/03/2008");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-04-19 15:17:35 +00:00
|
|
|
var beforeShowThis = null,
|
|
|
|
beforeShowInput = null,
|
|
|
|
beforeShowInst = null,
|
|
|
|
beforeShowDayThis = null,
|
|
|
|
beforeShowDayOK = true;
|
|
|
|
|
2009-02-04 04:27:14 +00:00
|
|
|
function beforeAll(input, inst) {
|
|
|
|
beforeShowThis = this;
|
|
|
|
beforeShowInput = input;
|
|
|
|
beforeShowInst = inst;
|
2012-12-26 13:08:48 +00:00
|
|
|
return {currentText: "Current"};
|
2009-02-04 04:27:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function beforeDay(date) {
|
|
|
|
beforeShowDayThis = this;
|
|
|
|
beforeShowDayOK &= (date > new Date(2008, 1 - 1, 26) &&
|
|
|
|
date < new Date(2008, 3 - 1, 6));
|
2012-12-26 13:08:48 +00:00
|
|
|
return [(date.getDate() % 2 === 0), (date.getDate() % 10 === 0 ? "day10" : ""),
|
|
|
|
(date.getDate() % 3 === 0 ? "Divisble by 3" : "")];
|
2009-02-04 04:27:14 +00:00
|
|
|
}
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("callbacks", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 13 );
|
2009-02-04 04:27:14 +00:00
|
|
|
// Before show
|
2012-04-19 15:17:35 +00:00
|
|
|
var dp, day20, day21,
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp", {beforeShow: beforeAll}),
|
2012-12-26 13:08:48 +00:00
|
|
|
inst = $.data(inp[0], "datepicker");
|
|
|
|
equal($.datepicker._get(inst, "currentText"), "Today", "Before show - initial");
|
|
|
|
inp.val("02/04/2008").datepicker("show");
|
|
|
|
equal($.datepicker._get(inst, "currentText"), "Current", "Before show - changed");
|
|
|
|
ok(beforeShowThis.id === inp[0].id, "Before show - this OK");
|
|
|
|
ok(beforeShowInput.id === inp[0].id, "Before show - input OK");
|
|
|
|
deepEqual(beforeShowInst, inst, "Before show - inst OK");
|
|
|
|
inp.datepicker("hide").datepicker("destroy");
|
2009-02-04 04:27:14 +00:00
|
|
|
// Before show day
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp", {beforeShowDay: beforeDay});
|
2012-12-26 13:08:48 +00:00
|
|
|
dp = $("#ui-datepicker-div");
|
|
|
|
inp.val("02/04/2008").datepicker("show");
|
|
|
|
ok(beforeShowDayThis.id === inp[0].id, "Before show day - this OK");
|
|
|
|
ok(beforeShowDayOK, "Before show day - dates OK");
|
|
|
|
day20 = dp.find(".ui-datepicker-calendar td:contains('20')");
|
|
|
|
day21 = dp.find(".ui-datepicker-calendar td:contains('21')");
|
|
|
|
ok(!day20.is(".ui-datepicker-unselectable"), "Before show day - unselectable 20");
|
|
|
|
ok(day21.is(".ui-datepicker-unselectable"), "Before show day - unselectable 21");
|
|
|
|
ok(day20.is(".day10"), "Before show day - CSS 20");
|
|
|
|
ok(!day21.is(".day10"), "Before show day - CSS 21");
|
|
|
|
ok(!day20.attr("title"), "Before show day - title 20");
|
|
|
|
ok(day21.attr("title") === "Divisble by 3", "Before show day - title 21");
|
2013-02-01 21:52:04 +00:00
|
|
|
inp.datepicker("hide").datepicker("destroy");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("beforeShowDay - tooltips with quotes", function() {
|
|
|
|
expect( 1 );
|
|
|
|
var inp, dp;
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp", {
|
2013-02-01 21:52:04 +00:00
|
|
|
beforeShowDay: function() {
|
|
|
|
return [ true, "", "'" ];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dp = $("#ui-datepicker-div");
|
|
|
|
|
|
|
|
inp.datepicker("show");
|
|
|
|
equal( dp.find( ".ui-datepicker-calendar td:contains('9')").attr( "title" ), "'" );
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.datepicker("hide").datepicker("destroy");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("localisation", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 24 );
|
2012-04-19 15:17:35 +00:00
|
|
|
var dp, month, day, date,
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init("#inp", $.datepicker.regional.fr);
|
2012-12-26 13:08:48 +00:00
|
|
|
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");
|
|
|
|
$(".ui-datepicker-close", dp).simulate("mouseover");
|
|
|
|
equal($(".ui-datepicker-prev", dp).text(), "Précédent", "Localisation - previous");
|
|
|
|
equal($(".ui-datepicker-current", dp).text(), "Aujourd'hui", "Localisation - current");
|
|
|
|
equal($(".ui-datepicker-next", dp).text(), "Suivant", "Localisation - next");
|
2012-04-19 15:17:35 +00:00
|
|
|
month = 0;
|
2012-12-26 13:08:48 +00:00
|
|
|
$(".ui-datepicker-month option", dp).each(function() {
|
2012-04-19 15:17:35 +00:00
|
|
|
equal($(this).text(), $.datepicker.regional.fr.monthNamesShort[month],
|
2012-12-26 13:08:48 +00:00
|
|
|
"Localisation - month " + month);
|
2009-02-04 04:27:14 +00:00
|
|
|
month++;
|
|
|
|
});
|
2012-04-19 15:17:35 +00:00
|
|
|
day = 1;
|
2012-12-26 13:08:48 +00:00
|
|
|
$(".ui-datepicker-calendar th", dp).each(function() {
|
2012-04-19 15:17:35 +00:00
|
|
|
equal($(this).text(), $.datepicker.regional.fr.dayNamesMin[day],
|
2012-12-26 13:08:48 +00:00
|
|
|
"Localisation - day " + day);
|
2009-02-04 04:27:14 +00:00
|
|
|
day = (day + 1) % 7;
|
|
|
|
});
|
2012-12-26 13:08:48 +00:00
|
|
|
inp.simulate("keydown", {keyCode: $.ui.keyCode.ENTER});
|
2012-04-19 15:17:35 +00:00
|
|
|
date = new Date();
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(inp.val(), $.datepicker.regional.fr.dayNames[date.getDay()] + ", " +
|
|
|
|
date.getDate() + " " + $.datepicker.regional.fr.monthNames[date.getMonth()] +
|
|
|
|
" " + date.getFullYear(), "Localisation - formatting");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("noWeekends", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 31 );
|
2012-04-19 15:17:35 +00:00
|
|
|
var i, date;
|
|
|
|
for (i = 1; i <= 31; i++) {
|
|
|
|
date = new Date(2001, 1 - 1, i);
|
2012-12-26 13:08:48 +00:00
|
|
|
deepEqual($.datepicker.noWeekends(date), [(i + 1) % 7 >= 2, ""],
|
|
|
|
"No weekends " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("iso8601Week", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 12 );
|
2009-02-04 04:27:14 +00:00
|
|
|
var date = new Date(2000, 12 - 1, 31);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 52, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2001, 1 - 1, 1);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2001, 1 - 1, 7);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2001, 1 - 1, 8);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 2, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2003, 12 - 1, 28);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 52, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2003, 12 - 1, 29);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2004, 1 - 1, 4);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2004, 1 - 1, 5);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 2, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2009, 12 - 1, 28);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 53, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2010, 1 - 1, 3);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 53, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2010, 1 - 1, 4);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
date = new Date(2010, 1 - 1, 10);
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.iso8601Week(date), 1, "ISO 8601 week " + date);
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("parseDate", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 26 );
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.init("#inp");
|
2012-04-19 15:17:35 +00:00
|
|
|
var currentYear, gmtDate, fr, settings, zh;
|
2012-12-26 13:08:48 +00:00
|
|
|
ok($.datepicker.parseDate("d m y", "") == null, "Parse date empty");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("d m y", "3 2 01"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 2 - 1, 3), "Parse date d m y");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("dd mm yy", "03 02 2001"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 2 - 1, 3), "Parse date dd mm yy");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("d m y", "13 12 01"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 12 - 1, 13), "Parse date d m y");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("dd mm yy", "13 12 2001"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 12 - 1, 13), "Parse date dd mm yy");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("y-o", "01-34"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 2 - 1, 3), "Parse date y-o");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("yy-oo", "2001-347"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 12 - 1, 13), "Parse date yy-oo");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("oo yy", "348 2004"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2004, 12 - 1, 13), "Parse date oo yy");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("D d M y", "Sat 3 Feb 01"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 2 - 1, 3), "Parse date D d M y");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("d MM DD yy", "3 February Saturday 2001"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 2 - 1, 3), "Parse date dd MM DD yy");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Saturday, February 3, 2001"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 2 - 1, 3), "Parse date DD, MM d, yy");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("'day' d 'of' MM (''DD''), yy",
|
2012-12-26 13:08:48 +00:00
|
|
|
"day 3 of February ('Saturday'), 2001"), new Date(2001, 2 - 1, 3),
|
|
|
|
"Parse date 'day' d 'of' MM (''DD''), yy");
|
2012-04-19 15:17:35 +00:00
|
|
|
currentYear = new Date().getFullYear();
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000) + "-02-03"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(currentYear, 2 - 1, 3), "Parse date y-m-d - default cutuff");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 10) + "-02-03"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(currentYear+10, 2 - 1, 3), "Parse date y-m-d - default cutuff");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 11) + "-02-03"),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(currentYear-89, 2 - 1, 3), "Parse date y-m-d - default cutuff");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("y-m-d", "80-02-03", {shortYearCutoff: 80}),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2080, 2 - 1, 3), "Parse date y-m-d - cutoff 80");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("y-m-d", "81-02-03", {shortYearCutoff: 80}),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(1981, 2 - 1, 3), "Parse date y-m-d - cutoff 80");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 60) + "-02-03", {shortYearCutoff: "+60"}),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(currentYear + 60, 2 - 1, 3), "Parse date y-m-d - cutoff +60");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("y-m-d", (currentYear - 2000 + 61) + "-02-03", {shortYearCutoff: "+60"}),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(currentYear - 39, 2 - 1, 3), "Parse date y-m-d - cutoff +60");
|
2012-04-19 15:17:35 +00:00
|
|
|
gmtDate = new Date(2001, 2 - 1, 3);
|
2009-04-01 10:56:58 +00:00
|
|
|
gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset());
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("@", "981158400000"), gmtDate, "Parse date @");
|
|
|
|
testHelper.equalsDate($.datepicker.parseDate("!", "631167552000000000"), gmtDate, "Parse date !");
|
2012-11-09 21:27:45 +00:00
|
|
|
|
2012-04-19 15:17:35 +00:00
|
|
|
fr = $.datepicker.regional.fr;
|
|
|
|
settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
|
2009-02-04 04:27:14 +00:00
|
|
|
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("D d M y", "Lun. 9 avr. 01", settings),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 4 - 1, 9), "Parse date D M y with settings");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("d MM DD yy", "9 Avril Lundi 2001", settings),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 4 - 1, 9), "Parse date d MM DD yy with settings");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("DD, MM d, yy", "Lundi, Avril 9, 2001", settings),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2001, 4 - 1, 9), "Parse date DD, MM d, yy with settings");
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings),
|
2012-11-09 21:27:45 +00:00
|
|
|
new Date(2001, 4 - 1, 9), "Parse date 'jour' d 'de' MM (''DD''), yy with settings");
|
2011-05-04 20:06:27 +00:00
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
zh = $.datepicker.regional["zh-CN"];
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.equalsDate($.datepicker.parseDate("yy M d", "2011 十一月 22", zh),
|
2012-12-26 13:08:48 +00:00
|
|
|
new Date(2011, 11 - 1, 22), "Parse date yy M d with zh-CN");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("parseDateErrors", function() {
|
2014-05-15 21:16:09 +00:00
|
|
|
expect( 18 );
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.init("#inp");
|
2012-04-19 15:17:35 +00:00
|
|
|
var fr, settings;
|
|
|
|
function expectError(expr, value, error) {
|
2009-02-04 04:27:14 +00:00
|
|
|
try {
|
|
|
|
expr();
|
2012-12-26 13:08:48 +00:00
|
|
|
ok(false, "Parsed error " + value);
|
2009-02-04 04:27:14 +00:00
|
|
|
}
|
|
|
|
catch (e) {
|
2012-12-26 13:08:48 +00:00
|
|
|
equal(e, error, "Parsed error " + value);
|
2009-02-04 04:27:14 +00:00
|
|
|
}
|
2012-04-19 15:17:35 +00:00
|
|
|
}
|
2012-12-26 13:08:48 +00:00
|
|
|
expectError(function() { $.datepicker.parseDate(null, "Sat 2 01"); },
|
|
|
|
"Sat 2 01", "Invalid arguments");
|
|
|
|
expectError(function() { $.datepicker.parseDate("d m y", null); },
|
|
|
|
"null", "Invalid arguments");
|
|
|
|
expectError(function() { $.datepicker.parseDate("d m y", "Sat 2 01"); },
|
|
|
|
"Sat 2 01 - d m y", "Missing number at position 0");
|
|
|
|
expectError(function() { $.datepicker.parseDate("dd mm yy", "Sat 2 01"); },
|
|
|
|
"Sat 2 01 - dd mm yy", "Missing number at position 0");
|
|
|
|
expectError(function() { $.datepicker.parseDate("d m y", "3 Feb 01"); },
|
|
|
|
"3 Feb 01 - d m y", "Missing number at position 2");
|
|
|
|
expectError(function() { $.datepicker.parseDate("dd mm yy", "3 Feb 01"); },
|
|
|
|
"3 Feb 01 - dd mm yy", "Missing number at position 2");
|
2014-05-15 21:16:09 +00:00
|
|
|
expectError(function() { $.datepicker.parseDate("mm dd yy", "2 1 01"); },
|
|
|
|
"2 1 01 - dd mm yy", "Missing number at position 4");
|
2012-12-26 13:08:48 +00:00
|
|
|
expectError(function() { $.datepicker.parseDate("d m y", "3 2 AD01"); },
|
|
|
|
"3 2 AD01 - d m y", "Missing number at position 4");
|
|
|
|
expectError(function() { $.datepicker.parseDate("d m yy", "3 2 AD01"); },
|
|
|
|
"3 2 AD01 - dd mm yy", "Missing number at position 4");
|
|
|
|
expectError(function() { $.datepicker.parseDate("y-o", "01-D01"); },
|
|
|
|
"2001-D01 - y-o", "Missing number at position 3");
|
|
|
|
expectError(function() { $.datepicker.parseDate("yy-oo", "2001-D01"); },
|
|
|
|
"2001-D01 - yy-oo", "Missing number at position 5");
|
|
|
|
expectError(function() { $.datepicker.parseDate("D d M y", "D7 3 Feb 01"); },
|
|
|
|
"D7 3 Feb 01 - D d M y", "Unknown name at position 0");
|
|
|
|
expectError(function() { $.datepicker.parseDate("D d M y", "Sat 3 M2 01"); },
|
|
|
|
"Sat 3 M2 01 - D d M y", "Unknown name at position 6");
|
|
|
|
expectError(function() { $.datepicker.parseDate("DD, MM d, yy", "Saturday- Feb 3, 2001"); },
|
|
|
|
"Saturday- Feb 3, 2001 - DD, MM d, yy", "Unexpected literal at position 8");
|
|
|
|
expectError(function() { $.datepicker.parseDate("'day' d 'of' MM (''DD''), yy",
|
|
|
|
"day 3 of February (\"Saturday\"), 2001"); },
|
|
|
|
"day 3 of Mon2 ('Day7'), 2001", "Unexpected literal at position 19");
|
|
|
|
expectError(function() { $.datepicker.parseDate("d m y", "29 2 01"); },
|
|
|
|
"29 2 01 - d m y", "Invalid date");
|
2012-04-19 15:17:35 +00:00
|
|
|
fr = $.datepicker.regional.fr;
|
|
|
|
settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
|
2009-02-04 04:27:14 +00:00
|
|
|
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
|
2012-12-26 13:08:48 +00:00
|
|
|
expectError(function() { $.datepicker.parseDate("D d M y", "Mon 9 Avr 01", settings); },
|
|
|
|
"Mon 9 Avr 01 - D d M y", "Unknown name at position 0");
|
|
|
|
expectError(function() { $.datepicker.parseDate("D d M y", "Lun. 9 Apr 01", settings); },
|
|
|
|
"Lun. 9 Apr 01 - D d M y", "Unknown name at position 7");
|
2009-02-04 04:27:14 +00:00
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("Ticket #7244: date parser does not fail when too many numbers are passed into the date function", function() {
|
2012-11-09 21:27:45 +00:00
|
|
|
expect( 4 );
|
|
|
|
var date;
|
|
|
|
try{
|
2012-12-26 13:08:48 +00:00
|
|
|
date = $.datepicker.parseDate("dd/mm/yy", "18/04/19881");
|
2012-11-09 21:27:45 +00:00
|
|
|
ok(false, "Did not properly detect an invalid date");
|
|
|
|
}catch(e){
|
|
|
|
ok("invalid date detected");
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2012-12-26 13:08:48 +00:00
|
|
|
date = $.datepicker.parseDate("dd/mm/yy", "18/04/1988 @ 2:43 pm");
|
2012-11-09 21:27:45 +00:00
|
|
|
equal(date.getDate(), 18);
|
|
|
|
equal(date.getMonth(), 3);
|
|
|
|
equal(date.getFullYear(), 1988);
|
|
|
|
} catch(e) {
|
|
|
|
ok(false, "Did not properly parse date with extra text separated by whitespace");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-12-26 13:08:48 +00:00
|
|
|
test("formatDate", function() {
|
2012-06-27 15:32:48 +00:00
|
|
|
expect( 16 );
|
2015-04-07 14:30:07 +00:00
|
|
|
testHelper.init("#inp");
|
2012-04-19 15:17:35 +00:00
|
|
|
var gmtDate, fr, settings;
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.formatDate("d m y", new Date(2001, 2 - 1, 3)),
|
|
|
|
"3 2 01", "Format date d m y");
|
|
|
|
equal($.datepicker.formatDate("dd mm yy", new Date(2001, 2 - 1, 3)),
|
|
|
|
"03 02 2001", "Format date dd mm yy");
|
|
|
|
equal($.datepicker.formatDate("d m y", new Date(2001, 12 - 1, 13)),
|
|
|
|
"13 12 01", "Format date d m y");
|
|
|
|
equal($.datepicker.formatDate("dd mm yy", new Date(2001, 12 - 1, 13)),
|
|
|
|
"13 12 2001", "Format date dd mm yy");
|
|
|
|
equal($.datepicker.formatDate("yy-o", new Date(2001, 2 - 1, 3)),
|
|
|
|
"2001-34", "Format date yy-o");
|
|
|
|
equal($.datepicker.formatDate("yy-oo", new Date(2001, 2 - 1, 3)),
|
|
|
|
"2001-034", "Format date yy-oo");
|
|
|
|
equal($.datepicker.formatDate("D M y", new Date(2001, 2 - 1, 3)),
|
|
|
|
"Sat Feb 01", "Format date D M y");
|
|
|
|
equal($.datepicker.formatDate("DD MM yy", new Date(2001, 2 - 1, 3)),
|
|
|
|
"Saturday February 2001", "Format date DD MM yy");
|
|
|
|
equal($.datepicker.formatDate("DD, MM d, yy", new Date(2001, 2 - 1, 3)),
|
|
|
|
"Saturday, February 3, 2001", "Format date DD, MM d, yy");
|
|
|
|
equal($.datepicker.formatDate("'day' d 'of' MM (''DD''), yy",
|
|
|
|
new Date(2001, 2 - 1, 3)), "day 3 of February ('Saturday'), 2001",
|
|
|
|
"Format date 'day' d 'of' MM ('DD'), yy");
|
2012-04-19 15:17:35 +00:00
|
|
|
gmtDate = new Date(2001, 2 - 1, 3);
|
2009-04-01 10:56:58 +00:00
|
|
|
gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset());
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.formatDate("@", gmtDate), "981158400000", "Format date @");
|
|
|
|
equal($.datepicker.formatDate("!", gmtDate), "631167552000000000", "Format date !");
|
2012-04-19 15:17:35 +00:00
|
|
|
fr = $.datepicker.regional.fr;
|
|
|
|
settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
|
2009-02-04 04:27:14 +00:00
|
|
|
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.formatDate("D M y", new Date(2001, 4 - 1, 9), settings),
|
2014-10-07 15:21:04 +00:00
|
|
|
"lun. avr. 01", "Format date D M y with settings");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.formatDate("DD MM yy", new Date(2001, 4 - 1, 9), settings),
|
2013-05-31 08:35:44 +00:00
|
|
|
"lundi avril 2001", "Format date DD MM yy with settings");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.formatDate("DD, MM d, yy", new Date(2001, 4 - 1, 9), settings),
|
2013-05-31 08:35:44 +00:00
|
|
|
"lundi, avril 9, 2001", "Format date DD, MM d, yy with settings");
|
2012-12-26 13:08:48 +00:00
|
|
|
equal($.datepicker.formatDate("'jour' d 'de' MM (''DD''), yy",
|
2013-05-31 08:35:44 +00:00
|
|
|
new Date(2001, 4 - 1, 9), settings), "jour 9 de avril ('lundi'), 2001",
|
2012-12-26 13:08:48 +00:00
|
|
|
"Format date 'jour' d 'de' MM (''DD''), yy with settings");
|
2009-02-02 14:36:08 +00:00
|
|
|
});
|
|
|
|
|
2013-04-14 16:58:42 +00:00
|
|
|
// TODO: Fix this test so it isn't mysteriously flaky in Browserstack on certain OS/Browser combos
|
|
|
|
// test("Ticket 6827: formatDate day of year calculation is wrong during day lights savings time", function(){
|
|
|
|
// expect( 1 );
|
|
|
|
// var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
|
|
|
|
// equal(time, "089");
|
|
|
|
// });
|
2012-11-09 21:27:45 +00:00
|
|
|
|
2013-04-07 18:40:26 +00:00
|
|
|
test( "Ticket 7602: Stop datepicker from appearing with beforeShow event handler", function() {
|
2012-11-09 21:27:45 +00:00
|
|
|
expect( 3 );
|
|
|
|
|
2013-04-07 18:40:26 +00:00
|
|
|
var inp, dp;
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init( "#inp", {
|
2013-04-07 18:40:26 +00:00
|
|
|
beforeShow: function() {
|
2012-11-09 21:27:45 +00:00
|
|
|
}
|
|
|
|
});
|
2013-04-07 18:40:26 +00:00
|
|
|
dp = $( "#ui-datepicker-div" );
|
|
|
|
inp.datepicker( "show" );
|
|
|
|
equal( dp.css( "display" ), "block", "beforeShow returns nothing" );
|
|
|
|
inp.datepicker( "hide" ).datepicker( "destroy" );
|
2012-11-09 21:27:45 +00:00
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init( "#inp", {
|
2013-04-07 18:40:26 +00:00
|
|
|
beforeShow: function() {
|
2012-11-09 21:27:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2013-04-07 18:40:26 +00:00
|
|
|
dp = $( "#ui-datepicker-div" );
|
|
|
|
inp.datepicker( "show" );
|
|
|
|
equal( dp.css( "display" ), "block", "beforeShow returns true" );
|
|
|
|
inp.datepicker( "hide" );
|
|
|
|
inp.datepicker( "destroy" );
|
|
|
|
|
2015-04-07 14:30:07 +00:00
|
|
|
inp = testHelper.init( "#inp", {
|
2013-04-07 18:40:26 +00:00
|
|
|
beforeShow: function() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
dp = $( "#ui-datepicker-div" );
|
|
|
|
inp.datepicker( "show" );
|
|
|
|
equal( dp.css( "display" ), "none","beforeShow returns false" );
|
|
|
|
inp.datepicker( "destroy" );
|
2012-11-09 21:27:45 +00:00
|
|
|
});
|
|
|
|
|
2015-04-07 00:06:31 +00:00
|
|
|
} );
|