-/*\r
+/*\r
* datepicker unit tests\r
*/\r
(function($) {\r
function init(id, options) {\r
$.datepicker.setDefaults($.datepicker.regional['']);\r
var inp = $(id);\r
- inp.datepicker($.extend({speed: ''}, options || {}));\r
+ inp.datepicker($.extend({duration: ''}, options || {}));\r
return inp;\r
}\r
\r
equals($.datepicker._defaults.showOn, 'focus', 'Restore showOn');\r
});\r
\r
-test('remove', function() {\r
- var rem = init('#rem');\r
- ok(rem.is('.hasDatepicker'), 'Marker class set');\r
- ok($.data(rem[0], PROP_NAME), 'Datepicker instance present');\r
- rem.datepicker('destroy');\r
- rem = $('#rem');\r
- ok(!rem.is('.hasDatepicker'), 'Marker class cleared');\r
- ok(!$.data(rem[0], PROP_NAME), 'Datepicker instance absent');\r
- rem.datepicker({showOn: 'both', buttonImage: 'img/calendar.gif'});\r
- ok(rem.is('.hasDatepicker'), 'Marker class set');\r
- ok($.data(rem[0], PROP_NAME), 'Datepicker instance present');\r
- rem.datepicker('destroy');\r
- rem = $('#rem');\r
- ok(!rem.is('.hasDatepicker'), 'Marker class cleared');\r
- ok(!$.data(rem[0], PROP_NAME), 'Datepicker instance absent');\r
+test('destroy', function() {\r
+ var inp = init('#inp');\r
+ ok(inp.is('.hasDatepicker'), 'Default - marker class set');\r
+ ok($.data(inp[0], PROP_NAME), 'Default - instance present');\r
+ ok(inp.next().is('#alt'), 'Default - button absent');\r
+ inp.datepicker('destroy');\r
+ inp = $('#inp');\r
+ ok(!inp.is('.hasDatepicker'), 'Default - marker class cleared');\r
+ ok(!$.data(inp[0], PROP_NAME), 'Default - instance absent');\r
+ ok(inp.next().is('#alt'), 'Default - button absent');\r
+ // With button\r
+ inp= init('#inp', {showOn: 'both'});\r
+ ok(inp.is('.hasDatepicker'), 'Button - marker class set');\r
+ ok($.data(inp[0], PROP_NAME), 'Button - instance present');\r
+ ok(inp.next().text() == '...', 'Button - button added');\r
+ inp.datepicker('destroy');\r
+ inp = $('#inp');\r
+ ok(!inp.is('.hasDatepicker'), 'Button - marker class cleared');\r
+ ok(!$.data(inp[0], PROP_NAME), 'Button - instance absent');\r
+ ok(inp.next().is('#alt'), 'Button - button removed');\r
+ // With append text\r
+ inp = init('#inp', {appendText: 'Testing'});\r
+ ok(inp.is('.hasDatepicker'), 'Append - marker class set');\r
+ ok($.data(inp[0], PROP_NAME), 'Append - instance present');\r
+ ok(inp.next().text() == 'Testing', 'Append - append text added');\r
+ inp.datepicker('destroy');\r
+ inp = $('#inp');\r
+ ok(!inp.is('.hasDatepicker'), 'Append - marker class cleared');\r
+ ok(!$.data(inp[0], PROP_NAME), 'Append - instance absent');\r
+ ok(inp.next().is('#alt'), 'Append - append text removed');\r
+ // With both\r
+ inp= init('#inp', {showOn: 'both', buttonImageOnly: true,\r
+ buttonImage: 'img/calendar.gif', appendText: 'Testing'});\r
+ ok(inp.is('.hasDatepicker'), 'Both - marker class set');\r
+ ok($.data(inp[0], PROP_NAME), 'Both - instance present');\r
+ ok(inp.next()[0].nodeName.toLowerCase() == 'img', 'Both - button added');\r
+ ok(inp.next().next().text() == 'Testing', 'Both - append text added');\r
+ inp.datepicker('destroy');\r
+ inp = $('#inp');\r
+ ok(!inp.is('.hasDatepicker'), 'Both - marker class cleared');\r
+ ok(!$.data(inp[0], PROP_NAME), 'Both - instance absent');\r
+ ok(inp.next().is('#alt'), 'Both - button and append text absent');\r
});\r
\r
test('change', function() {\r
ok(!dp.is(':visible'), 'Focus - hidden on external click');\r
inp.datepicker('hide').datepicker('destroy');\r
// On button\r
- inp = $('#inp');\r
- inp.datepicker({speed: '', showOn: 'button', buttonText: 'Popup'});\r
+ inp = init('#inp', {showOn: 'button', buttonText: 'Popup'});\r
ok(!dp.is(':visible'), 'Button - initially hidden');\r
button = inp.siblings('button');\r
image = inp.siblings('img');\r
ok(!dp.is(':visible'), 'Button - hidden on second button click');\r
inp.datepicker('hide').datepicker('destroy');\r
// On image button\r
- inp = $('#inp');\r
- inp.datepicker({speed: '', showOn: 'button', buttonImageOnly: true,\r
+ inp = init('#inp', {showOn: 'button', buttonImageOnly: true,\r
buttonImage: 'img/calendar.gif', buttonText: 'Cal'});\r
ok(!dp.is(':visible'), 'Image button - initially hidden');\r
button = inp.siblings('button');\r
ok(button.length == 0, 'Image button - button absent');\r
image = inp.siblings('img');\r
ok(image.length == 1, 'Image button - image present');\r
+ equals(image.attr('src'), 'img/calendar.gif', 'Image button - image source');\r
equals(image.attr('title'), 'Cal', 'Image button - image text');\r
inp.focus();\r
ok(!dp.is(':visible'), 'Image button - not rendered on focus');\r
ok(!dp.is(':visible'), 'Image button - hidden on second image click');\r
inp.datepicker('hide').datepicker('destroy');\r
// On both\r
- inp = $('#inp');\r
- inp.datepicker({speed: '', showOn: 'both', buttonImage: 'img/calendar.gif'});\r
+ inp = init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'});\r
ok(!dp.is(':visible'), 'Both - initially hidden');\r
button = inp.siblings('button');\r
ok(button.length == 1, 'Both - button present');\r
ok(dp.is(':visible'), 'Both - rendered on button click');\r
button.click();\r
ok(!dp.is(':visible'), 'Both - hidden on second button click');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+});\r
+\r
+test('baseStructure', function() {\r
+ var dp = $('#ui-datepicker-div');\r
+ var inp = init('#inp');\r
+ inp.focus();\r
+ var iframe = ($.browser.msie && parseInt($.browser.version) < 7);\r
+ ok(dp.is(':visible'), 'Structure - datepicker visible');\r
+ ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');\r
+ ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');\r
+ equals(dp.children().length, 4 + (iframe ? 1 : 0), 'Structure - child count');\r
+ var control = dp.children(':first');\r
+ ok(control.is('div.ui-datepicker-control'), 'Structure - control division');\r
+ equals(control.children().length, 2, 'Structure - control child count');\r
+ ok(control.children(':first').is('div.ui-datepicker-clear'),\r
+ 'Structure - clear division');\r
+ ok(control.children(':last').is('div.ui-datepicker-close'),\r
+ 'Structure - close division');\r
+ var links = dp.children(':eq(1)');\r
+ ok(links.is('div.ui-datepicker-links'), 'Structure - links division');\r
+ equals(links.children().length, 3, 'Structure - links child count');\r
+ ok(links.children(':first').is('div.ui-datepicker-prev') &&\r
+ links.children(':first').html() != '',\r
+ 'Structure - prev division');\r
+ ok(links.children(':eq(1)').is('div.ui-datepicker-current') &&\r
+ links.children(':eq(1)').html() != '',\r
+ 'Structure - current division');\r
+ ok(links.children(':last').is('div.ui-datepicker-next') &&\r
+ links.children(':last').html() != '',\r
+ 'Structure - next division');\r
+ var month = dp.children(':eq(2)');\r
+ ok(month.is('div.ui-datepicker-one-month') && month.is('div.ui-datepicker-new-row'),\r
+ 'Structure - month division');\r
+ var header = month.children(':first');\r
+ ok(header.is('div.ui-datepicker-header'), 'Structure - month header division');\r
+ equals(header.children().length, 2, 'Structure - month header child count');\r
+ ok(header.children(':first').is('select.ui-datepicker-new-month'),\r
+ 'Structure - new month select');\r
+ ok(header.children(':last').is('select.ui-datepicker-new-year'),\r
+ 'Structure - new year select');\r
+ var table = month.children(':eq(1)');\r
+ ok(table.is('table.ui-datepicker'), 'Structure - month table');\r
+ ok(table.children(':first').is('thead'), 'Structure - month table thead');\r
+ var titles = table.children(':first').children(':first');\r
+ ok(titles.is('tr.ui-datepicker-title-row'), 'Structure - month table title row');\r
+ equals(titles.find('a').length, 7, 'Structure - month table title links');\r
+ ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body');\r
+ ok(table.children(':eq(1)').children('tr').length >= 4,\r
+ 'Structure - month table week count');\r
+ var week = table.children(':eq(1)').children(':first');\r
+ ok(week.is('tr.ui-datepicker-days-row'), 'Structure - month table week row');\r
+ equals(week.children().length, 7, 'Structure - week child count');\r
+ ok(week.children(':first').is('td.ui-datepicker-days-cell') &&\r
+ week.children(':first').is('.ui-datepicker-week-end-cell') &&\r
+ !week.children(':first').is('.ui-datepicker-week-col'),\r
+ 'Structure - month table first day cell');\r
+ ok(week.children(':eq(1)').is('td.ui-datepicker-days-cell') &&\r
+ !week.children(':eq(1)').is('.ui-datepicker-week-end-cell'),\r
+ 'Structure - month table second day cell');\r
+ ok(dp.children('.ui-datepicker-status').length == 0, 'Structure - status');\r
+ ok(dp.children('iframe').length == (iframe ? 1 : 0), 'Structure - iframe');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Multi-month 2\r
+ inp = init('#inp', {numberOfMonths: 2});\r
+ inp.focus();\r
+ ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month');\r
+ equals(dp.children().length, 5 + (iframe ? 1 : 0), 'Structure multi - child count');\r
+ month = dp.children(':eq(2)');\r
+ ok(month.is('div.ui-datepicker-one-month') && month.is('div.ui-datepicker-new-row'),\r
+ 'Structure multi - first month division');\r
+ month = dp.children(':eq(3)');\r
+ ok(month.is('div.ui-datepicker-one-month') && !month.is('div.ui-datepicker-new-row'),\r
+ 'Structure multi - second month division');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Multi-month [2, 2]\r
+ inp = init('#inp', {numberOfMonths: [2, 2]});\r
+ inp.focus();\r
+ ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month');\r
+ equals(dp.children().length, 7 + (iframe ? 1 : 0), 'Structure multi - child count');\r
+ month = dp.children(':eq(2)');\r
+ ok(month.is('div.ui-datepicker-one-month') && month.is('div.ui-datepicker-new-row'),\r
+ 'Structure multi - first month division');\r
+ month = dp.children(':eq(3)');\r
+ ok(month.is('div.ui-datepicker-one-month') && !month.is('div.ui-datepicker-new-row'),\r
+ 'Structure multi - second month division');\r
+ month = dp.children(':eq(4)');\r
+ ok(month.is('div.ui-datepicker-one-month') && month.is('div.ui-datepicker-new-row'),\r
+ 'Structure multi - third month division');\r
+ month = dp.children(':eq(5)');\r
+ ok(month.is('div.ui-datepicker-one-month') && !month.is('div.ui-datepicker-new-row'),\r
+ 'Structure multi - fourth month division');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+});\r
+\r
+test('customStructure', function() {\r
+ var dp = $('#ui-datepicker-div');\r
+ // Check right-to-left localisation\r
+ var inp = init('#inp', $.datepicker.regional['he']);\r
+ inp.focus();\r
+ var iframe = ($.browser.msie && parseInt($.browser.version) < 7);\r
+ ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left');\r
+ var links = dp.children(':eq(1)');\r
+ ok(links.is('div.ui-datepicker-links'), 'Structure - links division');\r
+ equals(links.children().length, 3, 'Structure - links child count');\r
+ ok(links.children(':first').is('div.ui-datepicker-next'),\r
+ 'Structure - next division');\r
+ ok(links.children(':eq(1)').is('div.ui-datepicker-current'),\r
+ 'Structure - current division');\r
+ ok(links.children(':last').is('div.ui-datepicker-prev'),\r
+ 'Structure - prev division');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Close at bottom\r
+ inp = init('#inp', {closeAtTop: false});\r
+ inp.focus();\r
+ equals(dp.children().length, 4 + (iframe ? 1 : 0),\r
+ 'Structure close at bottom - child count');\r
+ ok(dp.children(':first').is('div.ui-datepicker-links'),\r
+ 'Structure close at bottom - links division');\r
+ ok(dp.children(':last').prev().is('div.ui-datepicker-control'),\r
+ 'Structure close at bottom - control division');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Mandatory\r
+ inp = init('#inp', {mandatory: true});\r
+ inp.focus();\r
+ var control = dp.children(':first');\r
+ ok(control.is('div.ui-datepicker-control'),\r
+ 'Structure mandatory - control division');\r
+ equals(control.children().length, 1, 'Structure mandatory - control child count');\r
+ ok(control.children(':first').is('div.ui-datepicker-close'),\r
+ 'Structure mandatory - close division');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Hide prev/next\r
+ inp = init('#inp', {hideIfNoPrevNext: true,\r
+ minDate: new Date(2008, 2 - 1, 4), maxDate: new Date(2008, 2 - 1, 14)});\r
+ inp.val('02/10/2008').focus();\r
+ var links = dp.children(':eq(1)');\r
+ ok(links.is('div.ui-datepicker-links'),\r
+ 'Structure hide prev/next - links division');\r
+ equals(links.children().length, 2, 'Structure hide prev/next - links child count');\r
+ ok(links.children(':first').is('div.ui-datepicker-prev') &&\r
+ links.children(':first').html() == '',\r
+ 'Structure hide prev/next - prev division');\r
+ ok(links.children(':last').is('div.ui-datepicker-next') &&\r
+ links.children(':last').html() == '',\r
+ 'Structure hide prev/next - next division');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Can't change month\r
+ inp = init('#inp', {changeMonth: false});\r
+ inp.focus();\r
+ var header = dp.children(':eq(2)').children(':first');\r
+ equals(header.children().length, 1, 'Structure change month - header child count');\r
+ ok(header.children(':last').is('select.ui-datepicker-new-year'),\r
+ 'Structure change month - new year select');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Can't change year\r
+ inp = init('#inp', {changeYear: false});\r
+ inp.focus();\r
+ var header = dp.children(':eq(2)').children(':first');\r
+ equals(header.children().length, 1, 'Structure change year - header child count');\r
+ ok(header.children(':first').is('select.ui-datepicker-new-month'),\r
+ 'Structure change year - new month select');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Can't change first day of week\r
+ inp = init('#inp', {changeFirstDay: false});\r
+ inp.focus();\r
+ var titles = dp.find('.ui-datepicker-title-row');\r
+ equals(titles.children().length, 7, 'Structure change first day - titles child count');\r
+ equals(titles.find('a').length, 0, 'Structure change first day - titles links count');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Show weeks\r
+ inp = init('#inp', {showWeeks: true});\r
+ inp.focus();\r
+ titles = dp.find('.ui-datepicker-title-row');\r
+ equals(titles.children().length, 8, 'Structure show weeks - titles child count');\r
+ var week = dp.find('.ui-datepicker-days-row:first');\r
+ equals(week.children().length, 8, 'Structure show weeks - week child count');\r
+ ok(week.children(':first').is('td.ui-datepicker-week-col'),\r
+ 'Structure show weeks - week column');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Show status\r
+ inp = init('#inp', {showStatus: true});\r
+ inp.focus();\r
+ equals(dp.children().length, 6 + (iframe ? 1 : 0),\r
+ 'Structure show status - datepicker child count');\r
+ ok(dp.children(':last').prev().is('div.ui-datepicker-status'),\r
+ 'Structure show status - status division');\r
+ inp.datepicker('hide').datepicker('destroy');\r
});\r
\r
test('enableDisable', function() {\r
var inp = init('#inp');\r
- ok(!inp.datepicker('isDisabled'), 'Initially marked as enabled');\r
- ok(!inp[0].disabled, 'Field initially enabled');\r
+ ok(!inp.datepicker('isDisabled'), 'Enable/disable - initially marked as enabled');\r
+ ok(!inp[0].disabled, 'Enable/disable - field initially enabled');\r
+ inp.datepicker('disable');\r
+ ok(inp.datepicker('isDisabled'), 'Enable/disable - now marked as disabled');\r
+ ok(inp[0].disabled, 'Enable/disable - field now disabled');\r
+ inp.datepicker('enable');\r
+ ok(!inp.datepicker('isDisabled'), 'Enable/disable - now marked as enabled');\r
+ ok(!inp[0].disabled, 'Enable/disable - field now enabled');\r
+ inp.datepicker('destroy');\r
+ // With a button\r
+ inp = init('#inp', {showOn: 'button'});\r
+ ok(!inp.datepicker('isDisabled'), 'Enable/disable button - initially marked as enabled');\r
+ ok(!inp[0].disabled, 'Enable/disable button - field initially enabled');\r
+ ok(!inp.next('button')[0].disabled, 'Enable/disable button - button initially enabled');\r
inp.datepicker('disable');\r
- ok(inp.datepicker('isDisabled'), 'Now marked as disabled');\r
- ok(inp[0].disabled, 'Field now disabled');\r
+ ok(inp.datepicker('isDisabled'), 'Enable/disable button - now marked as disabled');\r
+ ok(inp[0].disabled, 'Enable/disable button - field now disabled');\r
+ ok(inp.next('button')[0].disabled, 'Enable/disable button - button now disabled');\r
inp.datepicker('enable');\r
- ok(!inp.datepicker('isDisabled'), 'Now marked as enabled');\r
- ok(!inp[0].disabled, 'Field now enabled');\r
+ ok(!inp.datepicker('isDisabled'), 'Enable/disable button - now marked as enabled');\r
+ ok(!inp[0].disabled, 'Enable/disable button - field now enabled');\r
+ ok(!inp.next('button')[0].disabled, 'Enable/disable button - button now enabled');\r
+ inp.datepicker('destroy');\r
+ // With an image button\r
+ inp = init('#inp', {showOn: 'button', buttonImageOnly: true,\r
+ buttonImage: 'img/calendar.gif'});\r
+ ok(!inp.datepicker('isDisabled'), 'Enable/disable image - initially marked as enabled');\r
+ ok(!inp[0].disabled, 'Enable/disable image - field initially enabled');\r
+ ok(inp.next('img').css('opacity') == 1, 'Enable/disable image - image initially enabled');\r
+ inp.datepicker('disable');\r
+ ok(inp.datepicker('isDisabled'), 'Enable/disable image - now marked as disabled');\r
+ ok(inp[0].disabled, 'Enable/disable image - field now disabled');\r
+ ok(inp.next('img').css('opacity') != 1, 'Enable/disable image - image now disabled');\r
+ inp.datepicker('enable');\r
+ ok(!inp.datepicker('isDisabled'), 'Enable/disable image - now marked as enabled');\r
+ ok(!inp[0].disabled, 'Enable/disable image - field now enabled');\r
+ ok(inp.next('img').css('opacity') == 1, 'Enable/disable image - image now enabled');\r
+ inp.datepicker('destroy');\r
});\r
\r
test('keystrokes', function() {\r
equalsDate(inp.datepicker('getDate'), date, 'Keystroke enter');\r
inp.val('02/04/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), 'Keystroke enter - preset');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
+ 'Keystroke enter - preset');\r
inp.val('02/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_HOME}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
ok(inp.datepicker('getDate') == null, 'Keystroke esc');\r
inp.val('02/04/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), 'Keystroke esc - preset');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
+ 'Keystroke esc - preset');\r
inp.val('02/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), 'Keystroke esc - abandoned');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
+ 'Keystroke esc - abandoned');\r
// Moving by day or week\r
inp.val('').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_LEFT}).\r
inp.val('02/04/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 4), 'Keystroke pgup');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 4),\r
+ 'Keystroke pgup');\r
inp.val('02/04/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 4), 'Keystroke pgdn');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 4),\r
+ 'Keystroke pgdn');\r
inp.val('02/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 4), 'Keystroke ctrl+pgup');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 4),\r
+ 'Keystroke ctrl+pgup');\r
inp.val('02/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 4), 'Keystroke ctrl+pgdn');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 4),\r
+ 'Keystroke ctrl+pgdn');\r
// Check for moving to short months\r
inp.val('03/31/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29), 'Keystroke pgup - Feb');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29),\r
+ 'Keystroke pgup - Feb');\r
inp.val('01/30/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29), 'Keystroke pgdn - Feb');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29), \r
+ 'Keystroke pgdn - Feb');\r
inp.val('02/29/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 28), 'Keystroke ctrl+pgup - Feb');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2007, 2 - 1, 28),\r
+ 'Keystroke ctrl+pgup - Feb');\r
inp.val('02/29/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 28), 'Keystroke ctrl+pgdn - Feb');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2009, 2 - 1, 28),\r
+ 'Keystroke ctrl+pgdn - Feb');\r
+ // Goto current\r
+ inp.datepicker('change', {gotoCurrent: true});\r
+ inp.datepicker('hide').val('02/04/2008').datepicker('show');\r
+ inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_HOME}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
+ 'Keystroke ctrl+home');\r
});\r
\r
test('mouse', function() {\r
equalsDate(inp.datepicker('getDate'), date, 'Mouse click');\r
inp.val('02/04/2008').datepicker('show');\r
$('.ui-datepicker tbody a:contains(12)', dp).simulate('click', {});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 12), 'Mouse click - preset');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 12),\r
+ 'Mouse click - preset');\r
inp.val('02/04/2008').datepicker('show');\r
$('.ui-datepicker-clear a', dp).simulate('click', {});\r
ok(inp.datepicker('getDate') == null, 'Mouse click - clear');\r
ok(inp.datepicker('getDate') == null, 'Mouse click - close');\r
inp.val('02/04/2008').datepicker('show');\r
$('.ui-datepicker-close a', dp).simulate('click', {});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), 'Mouse click - close + preset');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
+ 'Mouse click - close + preset');\r
inp.val('02/04/2008').datepicker('show');\r
$('.ui-datepicker-prev a', dp).simulate('click', {});\r
$('.ui-datepicker-close a', dp).simulate('click', {});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4), 'Mouse click - abandoned');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 4),\r
+ 'Mouse click - abandoned');\r
// Current/previous/next\r
inp.val('02/04/2008').datepicker('show');\r
$('.ui-datepicker-current a', dp).simulate('click', {});\r
inp.val('02/04/2008').datepicker('show');\r
$('.ui-datepicker-prev a', dp).simulate('click', {});\r
$('.ui-datepicker tbody a:contains(16)', dp).simulate('click', {});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 16), 'Mouse click - previous');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 1 - 1, 16),\r
+ 'Mouse click - previous');\r
inp.val('02/04/2008').datepicker('show');\r
$('.ui-datepicker-next a', dp).simulate('click', {});\r
$('.ui-datepicker tbody a:contains(18)', dp).simulate('click', {});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 18), 'Mouse click - next');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 3 - 1, 18),\r
+ 'Mouse click - next');\r
// Previous/next with minimum/maximum\r
- inp.datepicker('change', {minDate: new Date(2008, 2 - 1, 2), maxDate: new Date(2008, 2 - 1, 26)}).\r
- val('02/04/2008').datepicker('show');\r
+ inp.datepicker('change', {minDate: new Date(2008, 2 - 1, 2),\r
+ maxDate: new Date(2008, 2 - 1, 26)}).val('02/04/2008').datepicker('show');\r
$('.ui-datepicker-prev a', dp).simulate('click', {});\r
$('.ui-datepicker tbody a:contains(16)', dp).simulate('click', {});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 16), 'Mouse click - previous + min/max');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 16),\r
+ 'Mouse click - previous + min/max');\r
inp.val('02/04/2008').datepicker('show');\r
$('.ui-datepicker-next a', dp).simulate('click', {});\r
$('.ui-datepicker tbody a:contains(18)', dp).simulate('click', {});\r
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 18), 'Mouse click - next + min/max');\r
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 18),\r
+ 'Mouse click - next + min/max');\r
// Change day of week\r
inp.val('02/04/2008').datepicker('show');\r
- equals($('.ui-datepicker-title-row td:first', dp).text(), 'Su', 'Mouse click - initial day of week');\r
+ equals($('.ui-datepicker-title-row td:first', dp).text(), 'Su',\r
+ 'Mouse click - initial day of week');\r
$('.ui-datepicker-title-row td:last a', dp).simulate('click', {});\r
- equals($('.ui-datepicker-title-row td:first', dp).text(), 'Sa', 'Mouse click - day of week');\r
+ equals($('.ui-datepicker-title-row td:first', dp).text(), 'Sa',\r
+ 'Mouse click - day of week');\r
+ // Highlight week\r
+ inp.datepicker('change', {highlightWeek: true}).\r
+ datepicker('hide').val('02/04/2008').datepicker('show');\r
+ ok(!$('.ui-datepicker tr:eq(2)', dp).is('.ui-datepicker-week-over'),\r
+ 'Mouse over - no week highlight');\r
+ $('.ui-datepicker tr:eq(2) td:first', dp).simulate('mouseover', {});\r
+ ok($('.ui-datepicker tr:eq(2)', dp).is('.ui-datepicker-week-over'),\r
+ 'Mouse over - week highlight');\r
});\r
\r
test('defaultDate', function() {\r
equalsDate(inp.datepicker('getDate'), date, 'Default date 01/26/2007');\r
});\r
\r
+test('miscellaneous', function() {\r
+ var dp = $('#ui-datepicker-div');\r
+ var inp = init('#inp');\r
+ // Year range\r
+ inp.val('02/04/2008').datepicker('show');\r
+ equals(dp.find('.ui-datepicker-new-year').text(),\r
+ '199819992000200120022003200420052006200720082009201020112012201320142015201620172018',\r
+ 'Year range - default');\r
+ inp.datepicker('hide').datepicker('change', {yearRange: '-6:+2'}).datepicker('show');\r
+ equals(dp.find('.ui-datepicker-new-year').text(),\r
+ '200220032004200520062007200820092010', 'Year range - -6:+2');\r
+ inp.datepicker('hide').datepicker('change', {yearRange: '2000:2010'}).datepicker('show');\r
+ equals(dp.find('.ui-datepicker-new-year').text(),\r
+ '20002001200220032004200520062007200820092010', 'Year range - 2000:2010');\r
+ // Navigation as date format\r
+ equals(dp.find('.ui-datepicker-prev').text(),\r
+ '<Prev', 'Navigation prev - default');\r
+ equals(dp.find('.ui-datepicker-current').text(),\r
+ 'Today', 'Navigation current - default');\r
+ equals(dp.find('.ui-datepicker-next').text(),\r
+ 'Next>', 'Navigation next - default');\r
+ inp.datepicker('hide').datepicker('change', {navigationAsDateFormat: true,\r
+ prevText: '< M', currentText: 'MM', nextText: 'M >'}).\r
+ val('02/04/2008').datepicker('show');\r
+ var longNames = $.datepicker.regional[''].monthNames;\r
+ var shortNames = $.datepicker.regional[''].monthNamesShort;\r
+ var date = new Date();\r
+ equals(dp.find('.ui-datepicker-prev').text(),\r
+ '< ' + shortNames[0], 'Navigation prev - as date format');\r
+ equals(dp.find('.ui-datepicker-current').text(),\r
+ longNames[date.getMonth()], 'Navigation current - as date format');\r
+ equals(dp.find('.ui-datepicker-next').text(),\r
+ shortNames[2] + ' >', 'Navigation next - as date format');\r
+ inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN});\r
+ equals(dp.find('.ui-datepicker-prev').text(),\r
+ '< ' + shortNames[1], 'Navigation prev - as date format + pgdn');\r
+ equals(dp.find('.ui-datepicker-current').text(),\r
+ longNames[date.getMonth()], 'Navigation current - as date format + pgdn');\r
+ equals(dp.find('.ui-datepicker-next').text(),\r
+ shortNames[3] + ' >', 'Navigation next - as date format + pgdn');\r
+ inp.datepicker('hide').datepicker('change', {gotoCurrent: true}).\r
+ val('02/04/2008').datepicker('show');\r
+ equals(dp.find('.ui-datepicker-prev').text(),\r
+ '< ' + shortNames[0], 'Navigation prev - as date format + goto current');\r
+ equals(dp.find('.ui-datepicker-current').text(),\r
+ longNames[1], 'Navigation current - as date format + goto current');\r
+ equals(dp.find('.ui-datepicker-next').text(),\r
+ shortNames[2] + ' >', 'Navigation next - as date format + goto current');\r
+});\r
+\r
test('minMax', function() {\r
var inp = init('#inp');\r
var lastYear = new Date(2007, 6 - 1, 4);\r
inp.val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), lastYear, 'Min/max - null, null - ctrl+pgup');\r
+ equalsDate(inp.datepicker('getDate'), lastYear,\r
+ 'Min/max - null, null - ctrl+pgup');\r
inp.val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), nextYear, 'Min/max - null, null - ctrl+pgdn');\r
- inp.datepicker('change', {minDate: minDate}).datepicker('hide').val('06/04/2008').datepicker('show');\r
+ equalsDate(inp.datepicker('getDate'), nextYear,\r
+ 'Min/max - null, null - ctrl+pgdn');\r
+ inp.datepicker('change', {minDate: minDate}).\r
+ datepicker('hide').val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - 02/29/2008, null - ctrl+pgup');\r
+ equalsDate(inp.datepicker('getDate'), minDate,\r
+ 'Min/max - 02/29/2008, null - ctrl+pgup');\r
inp.val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), nextYear, 'Min/max - 02/29/2008, null - ctrl+pgdn');\r
- inp.datepicker('change', {maxDate: maxDate}).datepicker('hide').val('06/04/2008').datepicker('show');\r
+ equalsDate(inp.datepicker('getDate'), nextYear,\r
+ 'Min/max - 02/29/2008, null - ctrl+pgdn');\r
+ inp.datepicker('change', {maxDate: maxDate}).\r
+ datepicker('hide').val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup');\r
+ equalsDate(inp.datepicker('getDate'), minDate,\r
+ 'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgup');\r
inp.val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn');\r
- inp.datepicker('change', {minDate: null}).datepicker('hide').val('06/04/2008').datepicker('show');\r
+ equalsDate(inp.datepicker('getDate'), maxDate,\r
+ 'Min/max - 02/29/2008, 12/07/2008 - ctrl+pgdn');\r
+ inp.datepicker('change', {minDate: null}).\r
+ datepicker('hide').val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), lastYear, 'Min/max - null, 12/07/2008 - ctrl+pgup');\r
+ equalsDate(inp.datepicker('getDate'), lastYear,\r
+ 'Min/max - null, 12/07/2008 - ctrl+pgup');\r
inp.val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - null, 12/07/2008 - ctrl+pgdn');\r
+ equalsDate(inp.datepicker('getDate'), maxDate,\r
+ 'Min/max - null, 12/07/2008 - ctrl+pgdn');\r
// relative dates\r
var date = new Date();\r
date.setDate(date.getDate() - 7);\r
datepicker('hide').val('').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), date, 'Min/max - -1w, +1 M +10 D - ctrl+pgup');\r
+ equalsDate(inp.datepicker('getDate'), date,\r
+ 'Min/max - -1w, +1 M +10 D - ctrl+pgup');\r
date = new Date();\r
date.setMonth(date.getMonth() + 1);\r
date.setDate(date.getDate() + 10);\r
inp.val('').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(inp.datepicker('getDate'), date, 'Min/max - -1w, +1 M +10 D - ctrl+pgdn');\r
+ equalsDate(inp.datepicker('getDate'), date,\r
+ 'Min/max - -1w, +1 M +10 D - ctrl+pgdn');\r
});\r
\r
test('setDate', function() {\r
date2 = new Date(2009, 7 - 1, 5);\r
inp.datepicker('change', {rangeSelect: true});\r
inp.datepicker('setDate', date1, date2);\r
- equalsDateArray(inp.datepicker('getDate'), [date1, date2], 'Set date range - 2008-06-04 - 2009-07-05');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date2],\r
+ 'Set date range - 2008-06-04 - 2009-07-05');\r
inp.datepicker('setDate', date1);\r
- equalsDateArray(inp.datepicker('getDate'), [date1, date1], 'Set date range - 2008-06-04');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date1],\r
+ 'Set date range - 2008-06-04');\r
date1 = new Date();\r
date1.setDate(date1.getDate() - 10);\r
date2 = new Date();\r
date2.setDate(date2.getDate() + 10);\r
inp.datepicker('setDate', -10, +10);\r
- equalsDateArray(inp.datepicker('getDate'), [date1, date2], 'Set date range - -10 - +10');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date2],\r
+ 'Set date range - -10 - +10');\r
inp.datepicker('setDate', -10);\r
- equalsDateArray(inp.datepicker('getDate'), [date1, date1], 'Set date range - -10');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date1],\r
+ 'Set date range - -10');\r
date1 = new Date();\r
date1.setDate(date1.getDate() - 14);\r
date2 = new Date();\r
date2.setFullYear(date2.getFullYear() + 1);\r
inp.datepicker('setDate', '-2w', '+1Y');\r
- equalsDateArray(inp.datepicker('getDate'), [date1, date2], 'Set date range - -2w - +1Y');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date2],\r
+ 'Set date range - -2w - +1Y');\r
inp.datepicker('setDate', '-2w');\r
- equalsDateArray(inp.datepicker('getDate'), [date1, date1], 'Set date range - -2w');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date1],\r
+ 'Set date range - -2w');\r
inp.datepicker('setDate');\r
isObj(inp.datepicker('getDate'), [null, null], 'Set date range - null');\r
});\r
\r
test('ranges', function() {\r
var inp = init('#inp', {rangeSelect: true});\r
- var d1 = new Date();\r
- var d2 = new Date();\r
+ var date1 = new Date();\r
+ var date2 = new Date();\r
// Select today - today\r
inp.val('').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDateArray(inp.datepicker('getDate'), [d1, d2], 'Range 1 month - enter/enter');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date1],\r
+ 'Range - enter/enter');\r
// Can't select prior to start date\r
inp.val('').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_UP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDateArray(inp.datepicker('getDate'), [d1, d2], 'Range 1 month - enter/ctrl+up/enter');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date1],\r
+ 'Range - enter/ctrl+up/enter');\r
// Can select after start date\r
inp.val('').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- d2.setDate(d2.getDate() + 7);\r
- equalsDateArray(inp.datepicker('getDate'), [d1, d2], 'Range 1 month - enter/ctrl+down/enter');\r
+ date2.setDate(date2.getDate() + 7);\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date2],\r
+ 'Range - enter/ctrl+down/enter');\r
+ equals(inp.val(), $.datepicker.formatDate('mm/dd/yy', date1) + ' - ' +\r
+ $.datepicker.formatDate('mm/dd/yy', date2), 'Range - value');\r
// Select then cancel defaults to first date\r
inp.val('').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
- equalsDateArray(inp.datepicker('getDate'), [d1, d1], 'Range 1 month - enter/ctrl+down/esc');\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date1],\r
+ 'Range - enter/ctrl+down/esc');\r
+ // Separator\r
+ inp.datepicker('change', {rangeSeparator: ' to '}).\r
+ datepicker('hide').val('06/04/2008').datepicker('show');\r
+ inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ equalsDateArray(inp.datepicker('getDate'),\r
+ [new Date(2008, 6 - 1, 4), new Date(2008, 6 - 1, 11)],\r
+ 'Range separator - enter/ctrl+down/enter');\r
+ equals(inp.val(), '06/04/2008 to 06/11/2008',\r
+ 'Range separator - value');\r
// Callbacks\r
- inp.datepicker('change', {onSelect: callback}).datepicker('hide').\r
- val('06/04/2008').datepicker('show');\r
+ inp.datepicker('change', {onSelect: callback, rangeSeparator: ' - '}).\r
+ datepicker('hide').val('06/04/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equals(selectedDate, '06/04/2008 - 06/11/2008', 'Range 1 month onSelect - enter/ctrl+down/enter');\r
- inp.datepicker('change', {onChangeMonthYear: callback, onSelect: null}).datepicker('hide').\r
- val('05/04/2008').datepicker('show');\r
+ equals(selectedDate, '06/04/2008 - 06/11/2008',\r
+ 'Range onSelect - enter/ctrl+down/enter');\r
+ inp.datepicker('change', {onChangeMonthYear: callback, onSelect: null}).\r
+ datepicker('hide').val('05/04/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDate(selectedDate, new Date(2008, 4 - 1, 1), 'Range 1 month onChangeMonthYear - enter/ctrl+down/enter');\r
- inp.datepicker('change', {onClose: callback, onChangeMonthYear: null}).datepicker('hide').\r
- val('03/04/2008').datepicker('show');\r
+ equalsDate(selectedDate, new Date(2008, 4 - 1, 1),\r
+ 'Range onChangeMonthYear - enter/ctrl+down/enter');\r
+ inp.datepicker('change', {onClose: callback, onChangeMonthYear: null}).\r
+ datepicker('hide').val('03/04/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equalsDateArray(selectedDate, [new Date(2008, 3 - 1, 4), new Date(2008, 3 - 1, 11)],\r
- 'Range 1 month onClose - enter/ctrl+down/enter');\r
+ equalsDateArray(selectedDate, [new Date(2008, 3 - 1, 4),\r
+ new Date(2008, 3 - 1, 11)], 'Range onClose - enter/ctrl+down/enter');\r
+ // Minimum/maximum\r
+ date1 = new Date(2008, 5 - 1, 20);\r
+ date2 = new Date(2008, 7 - 1, 2);\r
+ inp.datepicker('change', {minDate: date1, maxDate: date2, onChangeMonthYear: null}).\r
+ datepicker('hide').val('06/04/2008').datepicker('show');\r
+ inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ equalsDateArray(inp.datepicker('getDate'), [date1, date2],\r
+ 'Range min/max - pgup/enter/pgdn/pgdn/enter');\r
+ inp.val('06/04/2008').datepicker('show');\r
+ inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_UP}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
+ simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
+ simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
+ equalsDateArray(inp.datepicker('getDate'),\r
+ [new Date(2008, 5 - 1, 28), new Date(2008, 6 - 1, 11)],\r
+ 'Range min/max - ctrl+up/enter/ctrl+down/ctrl+down/enter');\r
});\r
\r
test('altField', function() {\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
- equals(inp.val(), '06/04/2008 - 07/04/2008', 'Alt field range - dp - enter/pgdn/enter');\r
- equals(alt.val(), '2008-06-04 - 2008-07-04', 'Alt field range - alt - enter/pgdn/enter');\r
+ equals(inp.val(), '06/04/2008 - 07/04/2008',\r
+ 'Alt field range - dp - enter/pgdn/enter');\r
+ equals(alt.val(), '2008-06-04 - 2008-07-04',\r
+ 'Alt field range - alt - enter/pgdn/enter');\r
// Range select escape\r
alt.val('');\r
inp.val('06/04/2008 - 07/14/2008').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER}).\r
simulate('keydown', {keyCode: $.simulate.VK_PGDN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
- equals(inp.val(), '06/04/2008 - 06/04/2008', 'Alt field range - dp - enter/pgdn/esc');\r
- equals(alt.val(), '2008-06-04 - 2008-06-04', 'Alt field range - alt - enter/pgdn/esc');\r
+ equals(inp.val(), '06/04/2008 - 06/04/2008',\r
+ 'Alt field range - dp - enter/pgdn/esc');\r
+ equals(alt.val(), '2008-06-04 - 2008-06-04',\r
+ 'Alt field range - alt - enter/pgdn/esc');\r
// Range select clear\r
alt.val('');\r
inp.val('06/04/2008 - 07/14/2008').datepicker('show');\r
equals(alt.val(), '', 'Alt field range - alt - enter/pgdn/ctrl+end');\r
});\r
\r
+var beforeShowThis = null;\r
+var beforeShowInput = null;\r
+var beforeShowInst = null;\r
+\r
+function beforeAll(input, inst) {\r
+ beforeShowThis = this;\r
+ beforeShowInput = input;\r
+ beforeShowInst = inst;\r
+ return {currentText: 'Current'};\r
+}\r
+\r
+var beforeShowDayThis = null;\r
+var beforeShowDayOK = true;\r
+\r
+function beforeDay(date) {\r
+ beforeShowDayThis = this;\r
+ beforeShowDayOK &= (date > new Date(2008, 1 - 1, 26) &&\r
+ date < new Date(2008, 3 - 1, 6));\r
+ return [(date.getDate() % 2 == 0), (date.getDate() % 10 == 0 ? 'day10' : ''),\r
+ (date.getDate() % 3 == 0 ? 'Divisble by 3' : '')];\r
+}\r
+\r
+function calcWeek(date) {\r
+ var doy = date.getDate() + 6;\r
+ for (var m = date.getMonth() - 1; m >= 0; m--)\r
+ doy += $.datepicker._getDaysInMonth(date.getFullYear(), m);\r
+ // Simple count from 01/01 starting at week 1\r
+ return Math.floor(doy / 7);\r
+}\r
+\r
+test('callbacks', function() {\r
+ // Before show\r
+ var inp = init('#inp', {beforeShow: beforeAll});\r
+ var inst = $.data(inp[0], 'datepicker');\r
+ equals($.datepicker._get(inst, 'currentText'), 'Today', 'Before show - initial');\r
+ inp.val('02/04/2008').datepicker('show');\r
+ equals($.datepicker._get(inst, 'currentText'), 'Current', 'Before show - changed');\r
+ ok(beforeShowThis.id == inp[0].id, 'Before show - this OK');\r
+ ok(beforeShowInput.id == inp[0].id, 'Before show - input OK');\r
+ isObj(beforeShowInst, inst, 'Before show - inst OK');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Before show day\r
+ inp = init('#inp', {beforeShowDay: beforeDay});\r
+ var dp = $('#ui-datepicker-div');\r
+ inp.val('02/04/2008').datepicker('show');\r
+ ok(beforeShowDayThis.id == inp[0].id, 'Before show day - this OK');\r
+ ok(beforeShowDayOK, 'Before show day - dates OK');\r
+ var day20 = dp.find('.ui-datepicker td:contains("20")');\r
+ var day21 = dp.find('.ui-datepicker td:contains("21")');\r
+ ok(!day20.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 20');\r
+ ok(day21.is('.ui-datepicker-unselectable'), 'Before show day - unselectable 21');\r
+ ok(day20.is('.day10'), 'Before show day - CSS 20');\r
+ ok(!day21.is('.day10'), 'Before show day - CSS 21');\r
+ ok(day20.attr('title') == '', 'Before show day - title 20');\r
+ ok(day21.attr('title') == 'Divisble by 3', 'Before show day - title 21');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+ // Calculate week\r
+ inp = init('#inp', {showWeeks: true, calculateWeek: calcWeek});\r
+ inp.val('02/04/2008').datepicker('show');\r
+ equals($('.ui-datepicker-week-col:first').text(), 4, 'Calculate week');\r
+ equals($('.ui-datepicker-week-col:last').text(), 8, 'Calculate week');\r
+ // Make Tuesday first\r
+ $('.ui-datepicker-title-row a:contains("Tu")', dp).simulate('click', {});\r
+ equals($('.ui-datepicker-week-col:first').text(), 5, 'Calculate week');\r
+ equals($('.ui-datepicker-week-col:last').text(), 9, 'Calculate week');\r
+ inp.datepicker('hide').datepicker('destroy');\r
+});\r
+\r
var selectedThis = null;\r
var selectedDate = null;\r
var selectedInst = null;\r
selectedInst = inst;\r
}\r
\r
-test('callbacks', function() {\r
+test('events', function() {\r
var inp = init('#inp', {onSelect: callback});\r
var date = new Date();\r
// onSelect\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
equals(selectedThis, inp[0], 'Callback selected this');\r
equals(selectedInst, $.data(inp[0], PROP_NAME), 'Callback selected inst');\r
- equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), 'Callback selected date');\r
+ equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),\r
+ 'Callback selected date');\r
inp.val('').datepicker('show');\r
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).\r
simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
date.setDate(date.getDate() + 7);\r
- equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), 'Callback selected date - ctrl+down');\r
+ equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),\r
+ 'Callback selected date - ctrl+down');\r
inp.val('').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ESC});\r
- equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date), 'Callback selected date - esc');\r
+ equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),\r
+ 'Callback selected date - esc');\r
// onChangeMonthYear\r
inp.datepicker('change', {onChangeMonthYear: callback, onSelect: null}).\r
val('').datepicker('show');\r
date.setFullYear(date.getFullYear() + 1);\r
equalsDate(selectedDate, date, 'Callback change month/year date - ctrl+pgdn');\r
// onChangeMonthYear step by 2\r
- inp.datepicker('change', {stepMonths: 2}).datepicker('hide').val('').datepicker('show');\r
+ inp.datepicker('change', {stepMonths: 2}).\r
+ datepicker('hide').val('').datepicker('show');\r
inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP});\r
date.setMonth(date.getMonth() - 14);\r
equalsDate(selectedDate, date, 'Callback change month/year by 2 date - pgup');\r
ok(selectedDate == null, 'Callback close date - ctrl+end');\r
});\r
\r
+function highlight20(date, inst) {\r
+ return (date.getDate() == 20 ? '*** 20 ***' : $.datepicker.dateStatus(date, inst));\r
+}\r
+\r
test('status', function() {\r
- var inp = init('#inp', {showStatus: true});\r
- inp.val('').datepicker('show');\r
var dp = $('#ui-datepicker-div');\r
+ var inp = init('#inp', {showStatus: true, statusForDate: highlight20, showWeeks: true});\r
+ inp.val('').datepicker('show');\r
var status = $('.ui-datepicker-status', dp);\r
+ ok(status.length == 1, 'Status - present');\r
equals(status.text(), 'Select a date', 'Status - default');\r
$('.ui-datepicker-clear a', dp).simulate('mouseover');\r
equals(status.text(), 'Erase the current date', 'Status - clear');\r
equals(status.text(), 'Show a different month', 'Status - new month');\r
$('.ui-datepicker-new-year', dp).simulate('mouseover');\r
equals(status.text(), 'Show a different year', 'Status - new year');\r
+ $('.ui-datepicker-title-row td:first', dp).simulate('mouseover');\r
+ equals(status.text(), 'Week of the year', 'Status - week header');\r
var day = 0;\r
$('.ui-datepicker-title-row a', dp).each(function() {\r
$(this).simulate('mouseover');\r
' as first week day', 'Status - day ' + day);\r
day++;\r
});\r
+ $('.ui-datepicker-days-row:eq(1) td:first', dp).simulate('mouseover');\r
+ equals(status.text(), 'Week of the year', 'Status - week column');\r
day = 0;\r
var month = $.datepicker.regional[''].monthNamesShort[new Date().getMonth()];\r
$('.ui-datepicker-days-row:eq(1) a', dp).each(function() {\r
', ' + month + ' ' + $(this).text(), 'Status - dates');\r
day++;\r
});\r
+ $('.ui-datepicker-days-row a:contains("20")', dp).each(function() {\r
+ $(this).simulate('mouseover');\r
+ equals(status.text(), '*** 20 ***', 'Status - dates');\r
+ });\r
+ inp.datepicker('hide').datepicker('destroy');\r
});\r
\r
test('localisation', function() {\r
var inp = init('#inp', $.datepicker.regional['fr']);\r
- inp.datepicker('change', {dateFormat: 'DD, d MM yy', showStatus: true}).\r
+ inp.datepicker('change', {dateFormat: 'DD, d MM yy', showStatus: true, showWeeks: true}).\r
val('').datepicker('show');\r
var dp = $('#ui-datepicker-div');\r
var status = $('.ui-datepicker-status', dp);\r
equals($('.ui-datepicker-close', dp).text(), 'Fermer', 'Localisation - close');\r
$('.ui-datepicker-close a', dp).simulate('mouseover');\r
equals(status.text(), 'Fermer sans modifier', 'Localisation - status');\r
- equals($('.ui-datepicker-prev', dp).text(), '<Préc', 'Localisation - previous');\r
+ equals($('.ui-datepicker-prev', dp).text(), '<Préc', 'Localisation - previous');\r
equals($('.ui-datepicker-current', dp).text(), 'Courant', 'Localisation - current');\r
equals($('.ui-datepicker-next', dp).text(), 'Suiv>', 'Localisation - next');\r
equals($('.ui-datepicker-current', dp).text(), 'Courant', 'Localisation - current');\r
'Localisation - month ' + month);\r
month++;\r
});\r
+ equals($('.ui-datepicker-title-row td:first', dp).text(),\r
+ $.datepicker.regional['fr'].weekHeader, 'Localisation - week header');\r
var day = 0;\r
- $('.ui-datepicker-title-row td', dp).each(function() {\r
+ $('.ui-datepicker-title-row a', dp).each(function() {\r
equals($(this).text(), $.datepicker.regional['fr'].dayNamesMin[day],\r
'Localisation - day ' + day);\r
day++;\r
});\r
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER});\r
var date = new Date();\r
- equals(inp.val(), $.datepicker.regional['fr'].dayNames[date.getDay()] +\r
- ', ' + date.getDate() + ' ' + $.datepicker.regional['fr'].monthNames[date.getMonth()] +\r
+ equals(inp.val(), $.datepicker.regional['fr'].dayNames[date.getDay()] + ', ' +\r
+ date.getDate() + ' ' + $.datepicker.regional['fr'].monthNames[date.getMonth()] +\r
' ' + date.getFullYear(), 'Localisation - formatting');\r
});\r
\r
});\r
\r
test('parseDate', function() {\r
+ init('#inp');\r
ok($.datepicker.parseDate('d m y', '') == null, 'Parse date empty');\r
equalsDate($.datepicker.parseDate('d m y', '3 2 01'),\r
new Date(2001, 2 - 1, 3), 'Parse date d m y');\r
new Date(2001, 12 - 1, 13), 'Parse date d m y');\r
equalsDate($.datepicker.parseDate('dd mm yy', '13 12 2001'),\r
new Date(2001, 12 - 1, 13), 'Parse date dd mm yy');\r
+ equalsDate($.datepicker.parseDate('y-o', '2001-34'),\r
+ new Date(2001, 2 - 1, 3), 'Parse date y-o');\r
+ equalsDate($.datepicker.parseDate('yy-oo', '2001-347'),\r
+ new Date(2001, 12 - 1, 13), 'Parse date yy oo');\r
+ equalsDate($.datepicker.parseDate('oo yy', '348 2004'),\r
+ new Date(2004, 12 - 1, 13), 'Parse date oo-yy');\r
equalsDate($.datepicker.parseDate('D d M y', 'Sat 3 Feb 01'),\r
new Date(2001, 2 - 1, 3), 'Parse date D d M y');\r
equalsDate($.datepicker.parseDate('d MM DD yy', '3 February Saturday 2001'),\r
new Date(2001, 2 - 1, 3), 'Parse date dd MM DD yy');\r
equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Saturday, February 3, 2001'),\r
new Date(2001, 2 - 1, 3), 'Parse date DD, MM d, yy');\r
- equalsDate($.datepicker.parseDate('\'day\' d of MM (\'\'DD\'\'), yy', 'day 3 of February (\'Saturday\'), 2001'),\r
- new Date(2001, 2 - 1, 3), 'Parse date \'day\' d of MM (\'\'DD\'\'), yy');\r
+ equalsDate($.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy',\r
+ 'day 3 of February (\'Saturday\'), 2001'), new Date(2001, 2 - 1, 3),\r
+ 'Parse date \'day\' d \'of\' MM (\'\'DD\'\'), yy');\r
equalsDate($.datepicker.parseDate('y-m-d', '01-02-03'),\r
new Date(2001, 2 - 1, 3), 'Parse date y-m-d - default cutoff');\r
equalsDate($.datepicker.parseDate('y-m-d', '51-02-03'),\r
new Date(2051, 2 - 1, 3), 'Parse date y-m-d - cutoff 80');\r
equalsDate($.datepicker.parseDate('y-m-d', '51-02-03', {shortYearCutoff: '+60'}),\r
new Date(2051, 2 - 1, 3), 'Parse date y-m-d - cutoff +60');\r
- var daysShort = ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7'];\r
- var daysLong = ['Day1', 'Day2', 'Day3', 'Day4', 'Day5', 'Day6', 'Day7'];\r
- var monthsShort = ['M1', 'M2', 'M3', 'M4', 'M5', 'M6',\r
- 'M7', 'M8', 'M9', 'M10', 'M11', 'M12'];\r
- var monthsLong = ['Mon1', 'Mon2', 'Mon3', 'Mon4', 'Mon5', 'Mon6', \r
- 'Mon7', 'Mon8', 'Mon9', 'Mon10', 'Mon11', 'Mon12'];\r
- var settings = {dayNamesShort: daysShort, dayNames: daysLong,\r
- monthNamesShort: monthsShort, monthNames: monthsLong};\r
- equalsDate($.datepicker.parseDate('D d M y', 'D7 3 M2 01', settings),\r
- new Date(2001, 2 - 1, 3), 'Parse date D M y with settings');\r
- equalsDate($.datepicker.parseDate('d MM DD yy', '3 Mon2 Day7 2001', settings),\r
- new Date(2001, 2 - 1, 3), 'Parse date d MM DD yy with settings');\r
- equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Day7, Mon2 3, 2001', settings),\r
- new Date(2001, 2 - 1, 3), 'Parse date DD, MM d, yy with settings');\r
- equalsDate($.datepicker.parseDate('\'day\' d of MM (\'\'DD\'\'), yy', 'day 3 of Mon2 (\'Day7\'), 2001', settings),\r
- new Date(2001, 2 - 1, 3), 'Parse date \'day\' d of MM (\'\'DD\'\'), yy with settings');\r
+ var fr = $.datepicker.regional['fr'];\r
+ var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,\r
+ monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};\r
+ equalsDate($.datepicker.parseDate('D d M y', 'Lun 9 Avr 01', settings),\r
+ new Date(2001, 4 - 1, 9), 'Parse date D M y with settings');\r
+ equalsDate($.datepicker.parseDate('d MM DD yy', '9 Avril Lundi 2001', settings),\r
+ new Date(2001, 4 - 1, 9), 'Parse date d MM DD yy with settings');\r
+ equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Lundi, Avril 9, 2001', settings),\r
+ new Date(2001, 4 - 1, 9), 'Parse date DD, MM d, yy with settings');\r
+ equalsDate($.datepicker.parseDate('\'jour\' d \'de\' MM (\'\'DD\'\'), yy',\r
+ 'jour 9 de Avril (\'Lundi\'), 2001', settings), new Date(2001, 4 - 1, 9),\r
+ 'Parse date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings');\r
});\r
\r
test('parseDateErrors', function() {\r
+ init('#inp');\r
var expectError = function(expr, value, error) {\r
try {\r
expr();\r
expectError(function() { $.datepicker.parseDate('d m y', null); },\r
'null', 'Invalid arguments');\r
expectError(function() { $.datepicker.parseDate('d m y', 'Sat 2 01'); },\r
- 'Sat 2 01', 'Missing number at position 0');\r
+ 'Sat 2 01 - d m y', 'Missing number at position 0');\r
+ expectError(function() { $.datepicker.parseDate('dd mm yy', 'Sat 2 01'); },\r
+ 'Sat 2 01 - dd mm yy', 'Missing number at position 0');\r
expectError(function() { $.datepicker.parseDate('d m y', '3 Feb 01'); },\r
- '3 Feb 01', 'Missing number at position 2');\r
+ '3 Feb 01 - d m y', 'Missing number at position 2');\r
+ expectError(function() { $.datepicker.parseDate('dd mm yy', '3 Feb 01'); },\r
+ '3 Feb 01 - dd mm yy', 'Missing number at position 2');\r
expectError(function() { $.datepicker.parseDate('d m y', '3 2 AD01'); },\r
- '3 2 AD01', 'Missing number at position 4');\r
+ '3 2 AD01 - d m y', 'Missing number at position 4');\r
+ expectError(function() { $.datepicker.parseDate('d m yy', '3 2 AD01'); },\r
+ '3 2 AD01 - dd mm yy', 'Missing number at position 4');\r
+ expectError(function() { $.datepicker.parseDate('y-o', '2001-D01'); },\r
+ '2001-D01 - y-o', 'Missing number at position 5');\r
+ expectError(function() { $.datepicker.parseDate('yy-oo', '2001-D01'); },\r
+ '2001-D01 - yy-oo', 'Missing number at position 5');\r
expectError(function() { $.datepicker.parseDate('D d M y', 'D7 3 Feb 01'); },\r
- 'D7 3 Feb 01', 'Unknown name at position 0');\r
+ 'D7 3 Feb 01 - D d M y', 'Unknown name at position 0');\r
expectError(function() { $.datepicker.parseDate('D d M y', 'Sat 3 M2 01'); },\r
- 'Sat 3 M2 01', 'Unknown name at position 6');\r
+ 'Sat 3 M2 01 - D d M y', 'Unknown name at position 6');\r
expectError(function() { $.datepicker.parseDate('DD, MM d, yy', 'Saturday- Feb 3, 2001'); },\r
- 'Sat- Feb 3, 2001', 'Unexpected literal at position 8');\r
- expectError(function() { $.datepicker.parseDate('\'day\' d of MM (\'\'DD\'\'), yy', 'day 3 of February ("Saturday"), 2001'); },\r
+ 'Saturday- Feb 3, 2001 - DD, MM d, yy', 'Unexpected literal at position 8');\r
+ expectError(function() { $.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy',\r
+ 'day 3 of February ("Saturday"), 2001'); },\r
'day 3 of Mon2 ("Day7"), 2001', 'Unexpected literal at position 19');\r
expectError(function() { $.datepicker.parseDate('d m y', '29 2 01'); },\r
- '29 2 01', 'Invalid date');\r
- var daysShort = ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7'];\r
- var daysLong = ['Day1', 'Day2', 'Day3', 'Day4', 'Day5', 'Day6', 'Day7'];\r
- var monthsShort = ['M1', 'M2', 'M3', 'M4', 'M5', 'M6',\r
- 'M7', 'M8', 'M9', 'M10', 'M11', 'M12'];\r
- var monthsLong = ['Mon1', 'Mon2', 'Mon3', 'Mon4', 'Mon5', 'Mon6', \r
- 'Mon7', 'Mon8', 'Mon9', 'Mon10', 'Mon11', 'Mon12'];\r
- var settings = {dayNamesShort: daysShort, dayNames: daysLong,\r
- monthNamesShort: monthsShort, monthNames: monthsLong};\r
- expectError(function() { $.datepicker.parseDate('D d M y', 'Sat 3 M2 01', settings); },\r
- 'Sat 3 M2 01', 'Unknown name at position 0');\r
- expectError(function() { $.datepicker.parseDate('D d M y', 'D7 3 Feb 01', settings); },\r
- 'D7 3 Feb 01', 'Unknown name at position 5');\r
+ '29 2 01 - d m y', 'Invalid date');\r
+ var fr = $.datepicker.regional['fr'];\r
+ var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,\r
+ monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};\r
+ expectError(function() { $.datepicker.parseDate('D d M y', 'Mon 9 Avr 01', settings); },\r
+ 'Mon 9 Avr 01 - D d M y', 'Unknown name at position 0');\r
+ expectError(function() { $.datepicker.parseDate('D d M y', 'Lun 9 Apr 01', settings); },\r
+ 'Lun 9 Apr 01 - D d M y', 'Unknown name at position 6');\r
});\r
\r
test('formatDate', function() {\r
+ init('#inp');\r
equals($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)),\r
'3 2 01', 'Format date d m y');\r
equals($.datepicker.formatDate('dd mm yy', new Date(2001, 2 - 1, 3)),\r
'13 12 01', 'Format date d m y');\r
equals($.datepicker.formatDate('dd mm yy', new Date(2001, 12 - 1, 13)),\r
'13 12 2001', 'Format date dd mm yy');\r
+ equals($.datepicker.formatDate('yy-o', new Date(2001, 2 - 1, 3)),\r
+ '2001-34', 'Format date yy-o');\r
+ equals($.datepicker.formatDate('yy-oo', new Date(2001, 2 - 1, 3)),\r
+ '2001-034', 'Format date yy-oo');\r
equals($.datepicker.formatDate('D M y', new Date(2001, 2 - 1, 3)),\r
'Sat Feb 01', 'Format date D M y');\r
equals($.datepicker.formatDate('DD MM yy', new Date(2001, 2 - 1, 3)),\r
'Saturday February 2001', 'Format date DD MM yy');\r
equals($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 2 - 1, 3)),\r
'Saturday, February 3, 2001', 'Format date DD, MM d, yy');\r
- equals($.datepicker.formatDate('\'day\' d of MM (\'\'DD\'\'), yy', new Date(2001, 2 - 1, 3)),\r
- 'day 3 of February (\'Saturday\'), 2001', 'Format date \'day\' d of MM (\'\'DD\'\'), yy');\r
- var daysShort = ['D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7'];\r
- var daysLong = ['Day1', 'Day2', 'Day3', 'Day4', 'Day5', 'Day6', 'Day7'];\r
- var monthsShort = ['M1', 'M2', 'M3', 'M4', 'M5', 'M6',\r
- 'M7', 'M8', 'M9', 'M10', 'M11', 'M12'];\r
- var monthsLong = ['Mon1', 'Mon2', 'Mon3', 'Mon4', 'Mon5', 'Mon6', \r
- 'Mon7', 'Mon8', 'Mon9', 'Mon10', 'Mon11', 'Mon12'];\r
- var settings = {dayNamesShort: daysShort, dayNames: daysLong,\r
- monthNamesShort: monthsShort, monthNames: monthsLong};\r
- equals($.datepicker.formatDate('D M y', new Date(2001, 2 - 1, 3), settings),\r
- 'D7 M2 01', 'Format date D M y with settings');\r
- equals($.datepicker.formatDate('DD MM yy', new Date(2001, 2 - 1, 3), settings),\r
- 'Day7 Mon2 2001', 'Format date DD MM yy with settings');\r
- equals($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 2 - 1, 3), settings),\r
- 'Day7, Mon2 3, 2001', 'Format date DD, MM d, yy with settings');\r
- equals($.datepicker.formatDate('\'day\' d of MM (\'\'DD\'\'), yy', new Date(2001, 2 - 1, 3), settings),\r
- 'day 3 of Mon2 (\'Day7\'), 2001', 'Format date \'day\' d of MM (\'\'DD\'\'), yy with settings');\r
+ equals($.datepicker.formatDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy',\r
+ new Date(2001, 2 - 1, 3)), 'day 3 of February (\'Saturday\'), 2001',\r
+ 'Format date \'day\' d \'of\' MM (\'\'DD\'\'), yy');\r
+ var fr = $.datepicker.regional['fr'];\r
+ var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,\r
+ monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};\r
+ equals($.datepicker.formatDate('D M y', new Date(2001, 4 - 1, 9), settings),\r
+ 'Lun Avr 01', 'Format date D M y with settings');\r
+ equals($.datepicker.formatDate('DD MM yy', new Date(2001, 4 - 1, 9), settings),\r
+ 'Lundi Avril 2001', 'Format date DD MM yy with settings');\r
+ equals($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 4 - 1, 9), settings),\r
+ 'Lundi, Avril 9, 2001', 'Format date DD, MM d, yy with settings');\r
+ equals($.datepicker.formatDate('\'jour\' d \'de\' MM (\'\'DD\'\'), yy',\r
+ new Date(2001, 4 - 1, 9), settings), 'jour 9 de Avril (\'Lundi\'), 2001',\r
+ 'Format date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings');\r
});\r
\r
})(jQuery);\r