diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/all-active.html | 2 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker.html | 1 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker_events.js | 19 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker_options.js | 68 | ||||
-rw-r--r-- | tests/unit/datepicker/datepicker_tickets.js | 88 |
5 files changed, 84 insertions, 94 deletions
diff --git a/tests/unit/all-active.html b/tests/unit/all-active.html index c32cde0fb..e9c343d00 100644 --- a/tests/unit/all-active.html +++ b/tests/unit/all-active.html @@ -20,7 +20,7 @@ "autocomplete/autocomplete.html", "button/button.html", "core/core.html", - //"datepicker/datepicker.html", + "datepicker/datepicker.html", "dialog/dialog.html", "draggable/draggable.html", "droppable/droppable.html", diff --git a/tests/unit/datepicker/datepicker.html b/tests/unit/datepicker/datepicker.html index c0c68979d..390d052c3 100644 --- a/tests/unit/datepicker/datepicker.html +++ b/tests/unit/datepicker/datepicker.html @@ -28,7 +28,6 @@ <script src="datepicker_methods.js"></script> <script src="datepicker_options.js"></script> <script src="datepicker_test_helpers.js"></script> - <script src="datepicker_tickets.js"></script> <script src="../swarminject.js"></script> </head> diff --git a/tests/unit/datepicker/datepicker_events.js b/tests/unit/datepicker/datepicker_events.js index 81b152c66..5e8a35e0d 100644 --- a/tests/unit/datepicker/datepicker_events.js +++ b/tests/unit/datepicker/datepicker_events.js @@ -126,4 +126,23 @@ test('events', function() { equal(selectedThis, inp2[0], 'Callback close this'); }); +test('beforeShowDay-getDate', function() { + expect( 3 ); + var inp = TestHelpers.datepicker.init('#inp', {beforeShowDay: function() { inp.datepicker('getDate'); return [true, '']; }}), + dp = $('#ui-datepicker-div'); + inp.val('01/01/2010').datepicker('show'); + // contains non-breaking space + equal($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month'); + $('a.ui-datepicker-next', dp).click(); + $('a.ui-datepicker-next', dp).click(); + // contains non-breaking space + equal($('div.ui-datepicker-title').text(), 'March 2010', 'After next clicks'); + inp.datepicker('hide').datepicker('show'); + $('a.ui-datepicker-prev', dp).click(); + $('a.ui-datepicker-prev', dp).click(); + // contains non-breaking space + equal($('div.ui-datepicker-title').text(), 'November 2009', 'After prev clicks'); + inp.datepicker('hide'); +}); + })(jQuery); diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 00910469e..df108309f 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -810,6 +810,7 @@ test('parseDate', function() { gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset()); TestHelpers.datepicker.equalsDate($.datepicker.parseDate('@', '981158400000'), gmtDate, 'Parse date @'); TestHelpers.datepicker.equalsDate($.datepicker.parseDate('!', '631167552000000000'), gmtDate, 'Parse date !'); + fr = $.datepicker.regional.fr; settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames, monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames}; @@ -819,12 +820,11 @@ test('parseDate', function() { new Date(2001, 4 - 1, 9), 'Parse date d MM DD yy with settings'); TestHelpers.datepicker.equalsDate($.datepicker.parseDate('DD, MM d, yy', 'Lundi, Avril 9, 2001', settings), new Date(2001, 4 - 1, 9), 'Parse date DD, MM d, yy with settings'); - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('\'jour\' d \'de\' MM (\'\'DD\'\'), yy', - 'jour 9 de Avril (\'Lundi\'), 2001', settings), new Date(2001, 4 - 1, 9), - 'Parse date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings'); + TestHelpers.datepicker.equalsDate($.datepicker.parseDate("'jour' d 'de' MM (''DD''), yy", "jour 9 de Avril ('Lundi'), 2001", settings), + new Date(2001, 4 - 1, 9), "Parse date 'jour' d 'de' MM (''DD''), yy with settings"); zh = $.datepicker.regional['zh-CN']; - TestHelpers.datepicker.equalsDate($.datepicker.parseDate('yy M d', '2011 十一 22', zh), + TestHelpers.datepicker.equalsDate($.datepicker.parseDate('yy M d', '2011 十一月 22', zh), new Date(2011, 11 - 1, 22), 'Parse date yy M d with zh-CN'); }); @@ -881,6 +881,26 @@ test('parseDateErrors', function() { 'Lun. 9 Apr 01 - D d M y', 'Unknown name at position 7'); }); +test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() { + expect( 4 ); + var date; + try{ + date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881'); + ok(false, "Did not properly detect an invalid date"); + }catch(e){ + ok("invalid date detected"); + } + + try { + date = $.datepicker.parseDate('dd/mm/yy', '18/04/1988 @ 2:43 pm'); + 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"); + } +}); + test('formatDate', function() { expect( 16 ); TestHelpers.datepicker.init('#inp'); @@ -924,4 +944,44 @@ test('formatDate', function() { 'Format date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings'); }); +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"); +}); + +test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){ + expect( 3 ); + var inp = TestHelpers.datepicker.init('#inp',{ + beforeShow: function(){ + return false; + } + }), + dp = $('#ui-datepicker-div'); + inp.datepicker('show'); + equal(dp.css('display'), 'none',"beforeShow returns false"); + inp.datepicker('destroy'); + + inp = TestHelpers.datepicker.init('#inp',{ + beforeShow: function(){ + } + }); + dp = $('#ui-datepicker-div'); + inp.datepicker('show'); + equal(dp.css('display'), 'block',"beforeShow returns nothing"); + inp.datepicker('hide'); + inp.datepicker('destroy'); + + inp = TestHelpers.datepicker.init('#inp',{ + beforeShow: function(){ + return true; + } + }); + dp = $('#ui-datepicker-div'); + inp.datepicker('show'); + equal(dp.css('display'), 'block',"beforeShow returns true"); + inp.datepicker('hide'); + inp.datepicker('destroy'); +}); + })(jQuery); diff --git a/tests/unit/datepicker/datepicker_tickets.js b/tests/unit/datepicker/datepicker_tickets.js deleted file mode 100644 index 4440992ae..000000000 --- a/tests/unit/datepicker/datepicker_tickets.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * datepicker_tickets.js - */ -(function($) { - -module("datepicker: tickets"); - -// http://forum.jquery.com/topic/several-breaking-changes-in-jquery-ui-1-8rc1 -test('beforeShowDay-getDate', function() { - expect( 3 ); - var inp = TestHelpers.datepicker.init('#inp', {beforeShowDay: function() { inp.datepicker('getDate'); return [true, '']; }}), - dp = $('#ui-datepicker-div'); - inp.val('01/01/2010').datepicker('show'); - // contains non-breaking space - equal($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month'); - $('a.ui-datepicker-next', dp).click(); - $('a.ui-datepicker-next', dp).click(); - // contains non-breaking space - equal($('div.ui-datepicker-title').text(), 'March 2010', 'After next clicks'); - inp.datepicker('hide').datepicker('show'); - $('a.ui-datepicker-prev', dp).click(); - $('a.ui-datepicker-prev', dp).click(); - // contains non-breaking space - equal($('div.ui-datepicker-title').text(), 'November 2009', 'After prev clicks'); - inp.datepicker('hide'); -}); - -test('Ticket 7602: Stop datepicker from appearing with beforeShow event handler', function(){ - expect( 3 ); - var inp = TestHelpers.datepicker.init('#inp',{ - beforeShow: function(){ - return false; - } - }), - dp = $('#ui-datepicker-div'); - inp.datepicker('show'); - equal(dp.css('display'), 'none',"beforeShow returns false"); - inp.datepicker('destroy'); - - inp = TestHelpers.datepicker.init('#inp',{ - beforeShow: function(){ - } - }); - dp = $('#ui-datepicker-div'); - inp.datepicker('show'); - equal(dp.css('display'), 'block',"beforeShow returns nothing"); - inp.datepicker('hide'); - inp.datepicker('destroy'); - - inp = TestHelpers.datepicker.init('#inp',{ - beforeShow: function(){ - return true; - } - }); - dp = $('#ui-datepicker-div'); - inp.datepicker('show'); - equal(dp.css('display'), 'block',"beforeShow returns true"); - inp.datepicker('hide'); - inp.datepicker('destroy'); -}); - -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"); -}); - -test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() { - expect( 4 ); - var date; - try{ - date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881'); - ok(false, "Did not properly detect an invalid date"); - }catch(e){ - ok("invalid date detected"); - } - - try { - date = $.datepicker.parseDate('dd/mm/yy', '18/04/1988 @ 2:43 pm'); - 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"); - } -}); - -})(jQuery); |