diff options
Diffstat (limited to 'tests/unit/datepicker/datepicker_options.js')
-rw-r--r-- | tests/unit/datepicker/datepicker_options.js | 231 |
1 files changed, 112 insertions, 119 deletions
diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index f538c6d03..3e200ecaa 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -16,8 +16,8 @@ test('setDefaults', function() { }); test('option', function() { - var inp = init('#inp'); - var inst = $.data(inp[0], PROP_NAME); + var inp = init('#inp'), + inst = $.data(inp[0], PROP_NAME); // Set option equal(inst.settings.showOn, null, 'Initial setting showOn'); equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn'); @@ -47,8 +47,8 @@ test('option', function() { }); test('change', function() { - var inp = init('#inp'); - var inst = $.data(inp[0], PROP_NAME); + var inp = init('#inp'), + inst = $.data(inp[0], PROP_NAME); equal(inst.settings.showOn, null, 'Initial setting showOn'); equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn'); equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn'); @@ -67,14 +67,15 @@ test('change', function() { }); test('invocation', function() { - var inp = init('#inp'); - var dp = $('#ui-datepicker-div'); - var body = $('body'); + var button, image, + inp = init('#inp'), + dp = $('#ui-datepicker-div'), + body = $('body'); // On focus - var button = inp.siblings('button'); - ok(button.length == 0, 'Focus - button absent'); - var image = inp.siblings('img'); - ok(image.length == 0, 'Focus - image absent'); + button = inp.siblings('button'); + ok(button.length === 0, 'Focus - button absent'); + image = inp.siblings('img'); + ok(image.length === 0, 'Focus - image absent'); inp.focus(); ok(dp.is(':visible'), 'Focus - rendered on focus'); inp.simulate('keydown', {keyCode: $.ui.keyCode.ESCAPE}); @@ -89,8 +90,8 @@ test('invocation', function() { 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'); + ok(button.length === 1, 'Button - button present'); + ok(image.length === 0, 'Button - image absent'); equal(button.text(), 'Popup', 'Button - button text'); inp.focus(); ok(!dp.is(':visible'), 'Button - not rendered on focus'); @@ -104,9 +105,9 @@ test('invocation', function() { buttonImage: 'img/calendar.gif', buttonText: 'Cal'}); ok(!dp.is(':visible'), 'Image button - initially hidden'); button = inp.siblings('button'); - ok(button.length == 0, 'Image button - button absent'); + ok(button.length === 0, 'Image button - button absent'); image = inp.siblings('img'); - ok(image.length == 1, 'Image button - image present'); + ok(image.length === 1, 'Image button - image present'); equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source'); equal(image.attr('title'), 'Cal', 'Image button - image text'); inp.focus(); @@ -120,11 +121,11 @@ test('invocation', function() { inp = init('#inp', {showOn: 'both', buttonImage: 'img/calendar.gif'}); ok(!dp.is(':visible'), 'Both - initially hidden'); button = inp.siblings('button'); - ok(button.length == 1, 'Both - button present'); + ok(button.length === 1, 'Both - button present'); image = inp.siblings('img'); - ok(image.length == 0, 'Both - image absent'); + ok(image.length === 0, 'Both - image absent'); image = button.children('img'); - ok(image.length == 1, 'Both - button image present'); + ok(image.length === 1, 'Both - button image present'); inp.focus(); ok(dp.is(':visible'), 'Both - rendered on focus'); body.simulate('mousedown', {}); @@ -137,29 +138,29 @@ test('invocation', function() { }); test('otherMonths', function() { - var inp = init('#inp'); - var pop = $('#ui-datepicker-div'); + var inp = init('#inp'), + pop = $('#ui-datepicker-div'); inp.val('06/01/2009').datepicker('show'); equal(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0', 'Other months - none'); - ok(pop.find('td:last *').length == 0, 'Other months - no content'); + 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'); + 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'); + 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(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0', 'Other months - none'); - ok(pop.find('td:last *').length == 0, 'Other months - no content'); + ok(pop.find('td:last *').length === 0, 'Other months - no content'); }); test('defaultDate', function() { - var inp = init('#inp'); - var date = new Date(); + var inp = init('#inp'), + date = new Date(); inp.val('').datepicker('show'). simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); equalsDate(inp.datepicker('getDate'), date, 'Default date null'); @@ -252,17 +253,19 @@ test('defaultDate', function() { }); test('miscellaneous', function() { - var dp = $('#ui-datepicker-div'); - var inp = init('#inp'); + var curYear, longNames, shortNames, date, + dp = $('#ui-datepicker-div'), + inp = init('#inp'); // Year range - var genRange = function(start, offset) { - var range = ''; - for (var i = start; i < start + offset; i++) { + function genRange(start, offset) { + var i = start, + range = ''; + for (; i < start + offset; i++) { range += i; } return range; - }; - var curYear = new Date().getFullYear(); + } + curYear = new Date().getFullYear(); 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'); @@ -285,9 +288,9 @@ test('miscellaneous', function() { 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'); - var longNames = $.datepicker.regional[''].monthNames; - var shortNames = $.datepicker.regional[''].monthNamesShort; - var date = new Date(); + longNames = $.datepicker.regional[''].monthNames; + shortNames = $.datepicker.regional[''].monthNamesShort; + date = new Date(); 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'); @@ -311,11 +314,12 @@ test('miscellaneous', function() { }); test('minMax', function() { - var inp = init('#inp'); - var lastYear = new Date(2007, 6 - 1, 4); - var nextYear = new Date(2009, 6 - 1, 4); - var minDate = new Date(2008, 2 - 1, 29); - var maxDate = new Date(2008, 12 - 1, 7); + var date, + inp = init('#inp'), + 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); inp.val('06/04/2008').datepicker('show'); inp.simulate('keydown', {ctrlKey: true, keyCode: $.ui.keyCode.PAGE_UP}). simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); @@ -360,7 +364,7 @@ test('minMax', function() { equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - null, 12/07/2008 - ctrl+pgdn'); // Relative dates - var date = new Date(); + date = new Date(); date.setDate(date.getDate() - 7); inp.datepicker('option', {minDate: '-1w', maxDate: '+1 M +10 D '}). datepicker('hide').val('').datepicker('show'); @@ -394,9 +398,10 @@ test('minMax', function() { }); test('setDate', function() { - var inp = init('#inp'); - var date1 = new Date(2008, 6 - 1, 4); - var date2 = new Date(); + var inl, alt, minDate, maxDate, dateAndTimeToSet, dateAndTimeClone, + inp = init('#inp'), + date1 = new Date(2008, 6 - 1, 4), + date2 = new Date(); ok(inp.datepicker('getDate') == null, 'Set date - default'); inp.datepicker('setDate', date1); equalsDate(inp.datepicker('getDate'), date1, 'Set date - 2008-06-04'); @@ -423,7 +428,7 @@ test('setDate', function() { inp.datepicker('setDate', 'c -3 w'); equalsDate(inp.datepicker('getDate'), date1, 'Set date - c -3 w'); // Inline - var inl = init('#inl'); + inl = init('#inl'); date1 = new Date(2008, 6 - 1, 4); date2 = new Date(); equalsDate(inl.datepicker('getDate'), date2, 'Set date inline - default'); @@ -441,7 +446,7 @@ test('setDate', function() { inl.datepicker('setDate'); ok(inl.datepicker('getDate') == null, 'Set date inline - null'); // Alternate field - var alt = $('#alt'); + alt = $('#alt'); inp.datepicker('option', {altField: '#alt', altFormat: 'yy-mm-dd'}); date1 = new Date(2008, 6 - 1, 4); inp.datepicker('setDate', date1); @@ -451,8 +456,8 @@ test('setDate', function() { inp = init('#inp'); date1 = new Date(2008, 1 - 1, 4); date2 = new Date(2008, 6 - 1, 4); - var minDate = new Date(2008, 2 - 1, 29); - var maxDate = new Date(2008, 3 - 1, 28); + minDate = new Date(2008, 2 - 1, 29); + maxDate = new Date(2008, 3 - 1, 28); inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date2); equalsDate(inp.datepicker('getDate'), date2, 'Set date min/max - setDate > min'); inp.datepicker('setDate', date1); @@ -465,15 +470,15 @@ test('setDate', function() { equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min'); inp.datepicker('setDate', date2); equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max'); - var dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0); - var dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0); + dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0); + dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0); inp.datepicker('setDate', dateAndTimeToSet); equal(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), 'Date object passed should not be changed by setDate'); }); test('altField', function() { - var inp = init('#inp'); - var alt = $('#alt'); + var inp = init('#inp'), + alt = $('#alt'); // No alternate field set alt.val(''); inp.val('06/04/2008').datepicker('show'); @@ -507,26 +512,6 @@ test('altField', function() { 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'); - - return - // TODO manual entry impl works (see altField demo) but this test doesn't - // probably something the rewrite won't cover anymore anyway - - // Verify alt field is updated on keyup - alt.val(''); - inp.val('06/04/200').datepicker('show'); - inp.simulate('keydown', {charCode: '8'.charCodeAt(0)}); - inp.simulate('keypress', {charCode: '8'.charCodeAt(0)}); - inp.simulate('keyup', {charCode: '8'.charCodeAt(0)}); - equal(inp.val(), '06/04/2008', 'Alt field - dp - manual entry'); - equal(alt.val(), '2008-06-04', 'Alt field - manual entry'); - // Verify alt field is not updated on keyup if date is invalid - inp.val('12/04'); - inp.simulate('keydown', {charCode: '/'.charCodeAt(0)}); - inp.simulate('keypress', {charCode: '/'.charCodeAt(0)}); - inp.simulate('keyup', {charCode: '/'.charCodeAt(0)}); - equal(inp.val(), '12/04/', 'Alt field - dp - manual entry incomplete'); - equal(alt.val(), '2008-06-04', 'Alt field - manual entry - not updated'); }); test('autoSize', function() { @@ -541,7 +526,7 @@ test('autoSize', function() { inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); equal(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy'); // French - inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['fr'])); + 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'); @@ -552,7 +537,7 @@ test('autoSize', function() { inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy'); equal(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy'); // Hebrew - inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['he'])); + 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'); @@ -565,8 +550,8 @@ test('autoSize', function() { }); test('daylightSaving', function() { - var inp = init('#inp'); - var dp = $('#ui-datepicker-div'); + var inp = init('#inp'), + dp = $('#ui-datepicker-div'); ok(true, 'Daylight saving - ' + new Date()); // Australia, Sydney - AM change, southern hemisphere inp.val('04/01/2008').datepicker('show'); @@ -646,9 +631,12 @@ test('daylightSaving', function() { equal(inp.val(), '11/03/2008', 'Daylight saving - US 11/03/2008'); }); -var beforeShowThis = null; -var beforeShowInput = null; -var beforeShowInst = null; +var beforeShowThis = null, + beforeShowInput = null, + beforeShowInst = null, + beforeShowDayThis = null, + beforeShowDayOK = true; + function beforeAll(input, inst) { beforeShowThis = this; @@ -657,84 +645,86 @@ function beforeAll(input, inst) { return {currentText: 'Current'}; } -var beforeShowDayThis = null; -var beforeShowDayOK = true; - function beforeDay(date) { beforeShowDayThis = this; beforeShowDayOK &= (date > new Date(2008, 1 - 1, 26) && date < new Date(2008, 3 - 1, 6)); - return [(date.getDate() % 2 == 0), (date.getDate() % 10 == 0 ? 'day10' : ''), - (date.getDate() % 3 == 0 ? 'Divisble by 3' : '')]; + return [(date.getDate() % 2 === 0), (date.getDate() % 10 === 0 ? 'day10' : ''), + (date.getDate() % 3 === 0 ? 'Divisble by 3' : '')]; } function calcWeek(date) { - var doy = date.getDate() + 6; - for (var m = date.getMonth() - 1; m >= 0; m--) + var doy = date.getDate() + 6, + m = date.getMonth() - 1; + for (; m >= 0; m--) { doy += $.datepicker._getDaysInMonth(date.getFullYear(), m); + } // Simple count from 01/01 starting at week 1 return Math.floor(doy / 7); } test('callbacks', function() { // Before show - var inp = init('#inp', {beforeShow: beforeAll}); - var inst = $.data(inp[0], 'datepicker'); + var dp, day20, day21, + inp = init('#inp', {beforeShow: beforeAll}), + inst = $.data(inp[0], 'datepicker'); equal($.datepicker._get(inst, 'currentText'), 'Today', 'Before show - initial'); inp.val('02/04/2008').datepicker('show'); 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'); + 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'); // Before show day inp = init('#inp', {beforeShowDay: beforeDay}); - var dp = $('#ui-datepicker-div'); + dp = $('#ui-datepicker-div'); inp.val('02/04/2008').datepicker('show'); - ok(beforeShowDayThis.id == inp[0].id, 'Before show day - this OK'); + ok(beforeShowDayThis.id === inp[0].id, 'Before show day - this OK'); ok(beforeShowDayOK, 'Before show day - dates OK'); - var day20 = dp.find('.ui-datepicker-calendar td:contains("20")'); - var day21 = dp.find('.ui-datepicker-calendar td:contains("21")'); + 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'); + ok(day21.attr('title') === 'Divisble by 3', 'Before show day - title 21'); inp.datepicker('hide').datepicker('destroy'); }); test('localisation', function() { - var inp = init('#inp', $.datepicker.regional['fr']); + var dp, month, day, date, + inp = init('#inp', $.datepicker.regional.fr); inp.datepicker('option', {dateFormat: 'DD, d MM yy', showButtonPanel:true, changeMonth:true, changeYear:true}).val('').datepicker('show'); - var dp = $('#ui-datepicker-div'); + 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'); - var month = 0; + month = 0; $('.ui-datepicker-month option', dp).each(function() { - equal($(this).text(), $.datepicker.regional['fr'].monthNamesShort[month], + equal($(this).text(), $.datepicker.regional.fr.monthNamesShort[month], 'Localisation - month ' + month); month++; }); - var day = 1; + day = 1; $('.ui-datepicker-calendar th', dp).each(function() { - equal($(this).text(), $.datepicker.regional['fr'].dayNamesMin[day], + equal($(this).text(), $.datepicker.regional.fr.dayNamesMin[day], 'Localisation - day ' + day); day = (day + 1) % 7; }); inp.simulate('keydown', {keyCode: $.ui.keyCode.ENTER}); - var date = new Date(); - equal(inp.val(), $.datepicker.regional['fr'].dayNames[date.getDay()] + ', ' + - date.getDate() + ' ' + $.datepicker.regional['fr'].monthNames[date.getMonth()] + + date = new Date(); + equal(inp.val(), $.datepicker.regional.fr.dayNames[date.getDay()] + ', ' + + date.getDate() + ' ' + $.datepicker.regional.fr.monthNames[date.getMonth()] + ' ' + date.getFullYear(), 'Localisation - formatting'); }); test('noWeekends', function() { - for (var i = 1; i <= 31; i++) { - var date = new Date(2001, 1 - 1, i); + var i, date; + for (i = 1; i <= 31; i++) { + date = new Date(2001, 1 - 1, i); deepEqual($.datepicker.noWeekends(date), [(i + 1) % 7 >= 2, ''], 'No weekends ' + date); } @@ -769,6 +759,7 @@ test('iso8601Week', function() { test('parseDate', function() { init('#inp'); + var currentYear, gmtDate, fr, settings, zh; ok($.datepicker.parseDate('d m y', '') == null, 'Parse date empty'); equalsDate($.datepicker.parseDate('d m y', '3 2 01'), new Date(2001, 2 - 1, 3), 'Parse date d m y'); @@ -793,7 +784,7 @@ test('parseDate', function() { equalsDate($.datepicker.parseDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy', 'day 3 of February (\'Saturday\'), 2001'), new Date(2001, 2 - 1, 3), 'Parse date \'day\' d \'of\' MM (\'\'DD\'\'), yy'); - var currentYear = new Date().getFullYear(); + currentYear = new Date().getFullYear(); equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000) + '-02-03'), new Date(currentYear, 2 - 1, 3), 'Parse date y-m-d - default cutuff'); equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 10) + '-02-03'), @@ -808,12 +799,12 @@ test('parseDate', function() { new Date(currentYear + 60, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); equalsDate($.datepicker.parseDate('y-m-d', (currentYear - 2000 + 61) + '-02-03', {shortYearCutoff: '+60'}), new Date(currentYear - 39, 2 - 1, 3), 'Parse date y-m-d - cutoff +60'); - var gmtDate = new Date(2001, 2 - 1, 3); + gmtDate = new Date(2001, 2 - 1, 3); gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); equalsDate($.datepicker.parseDate('@', '981158400000'), gmtDate, 'Parse date @'); equalsDate($.datepicker.parseDate('!', '631167552000000000'), gmtDate, 'Parse date !'); - var fr = $.datepicker.regional['fr']; - var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, + fr = $.datepicker.regional.fr; + settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; equalsDate($.datepicker.parseDate('D d M y', 'Lun. 9 Avril 01', settings), new Date(2001, 4 - 1, 9), 'Parse date D M y with settings'); @@ -825,14 +816,15 @@ test('parseDate', function() { 'jour 9 de Avril (\'Lundi\'), 2001', settings), new Date(2001, 4 - 1, 9), 'Parse date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings'); - var zh = $.datepicker.regional['zh-CN']; + zh = $.datepicker.regional['zh-CN']; equalsDate($.datepicker.parseDate('yy M d', '2011 十一 22', zh), new Date(2011, 11 - 1, 22), 'Parse date yy M d with zh-CN'); }); test('parseDateErrors', function() { init('#inp'); - var expectError = function(expr, value, error) { + var fr, settings; + function expectError(expr, value, error) { try { expr(); ok(false, 'Parsed error ' + value); @@ -840,7 +832,7 @@ test('parseDateErrors', function() { catch (e) { equal(e, error, 'Parsed error ' + value); } - }; + } expectError(function() { $.datepicker.parseDate(null, 'Sat 2 01'); }, 'Sat 2 01', 'Invalid arguments'); expectError(function() { $.datepicker.parseDate('d m y', null); }, @@ -872,8 +864,8 @@ test('parseDateErrors', function() { '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'); - var fr = $.datepicker.regional['fr']; - var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, + fr = $.datepicker.regional.fr; + settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; 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'); @@ -883,6 +875,7 @@ test('parseDateErrors', function() { test('formatDate', function() { init('#inp'); + var gmtDate, fr, settings; equal($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)), '3 2 01', 'Format date d m y'); equal($.datepicker.formatDate('dd mm yy', new Date(2001, 2 - 1, 3)), @@ -904,12 +897,12 @@ test('formatDate', function() { 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'); - var gmtDate = new Date(2001, 2 - 1, 3); + gmtDate = new Date(2001, 2 - 1, 3); gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); equal($.datepicker.formatDate('@', gmtDate), '981158400000', 'Format date @'); equal($.datepicker.formatDate('!', gmtDate), '631167552000000000', 'Format date !'); - var fr = $.datepicker.regional['fr']; - var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, + fr = $.datepicker.regional.fr; + settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; equal($.datepicker.formatDate('D M y', new Date(2001, 4 - 1, 9), settings), 'Lun. Avril 01', 'Format date D M y with settings'); |