Skip to content

Commit ffcc7f2

Browse files
committed
Datepicker: Add tests zero-padding by formatDate
1 parent bbefa77 commit ffcc7f2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tests/unit/datepicker/options.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ QUnit.test( "Ticket #7244: date parser does not fail when too many numbers are p
11241124
} );
11251125

11261126
QUnit.test( "formatDate", function( assert ) {
1127-
assert.expect( 16 );
1127+
assert.expect( 21 );
11281128
testHelper.init( "#inp" );
11291129
var gmtDate, fr, settings;
11301130
assert.equal( $.datepicker.formatDate( "d m y", new Date( 2001, 2 - 1, 3 ) ),
@@ -1164,6 +1164,14 @@ QUnit.test( "formatDate", function( assert ) {
11641164
assert.equal( $.datepicker.formatDate( "'jour' d 'de' MM (''DD''), yy",
11651165
new Date( 2001, 4 - 1, 9 ), settings ), "jour 9 de avril ('lundi'), 2001",
11661166
"Format date 'jour' d 'de' MM (''DD''), yy with settings" );
1167+
1168+
assert.equal( $.datepicker.formatDate( "yy-mm-dd", new Date( 100, 0, 1 ) ), "0100-01-01" );
1169+
assert.equal( $.datepicker.formatDate( "yy-mm-dd", new Date( 999, 0, 1 ) ), "0999-01-01" );
1170+
assert.equal( $.datepicker.formatDate( "yy-mm-dd", new Date( 1000, 0, 1 ) ), "1000-01-01" );
1171+
1172+
// -1 and 100000 will not be parsed correctly, but can be selected
1173+
assert.equal( $.datepicker.formatDate( "yy-mm-dd", new Date( -1, 0, 1 ) ), "-1-01-01" );
1174+
assert.equal( $.datepicker.formatDate( "yy-mm-dd", new Date( 10000, 0, 1 ) ), "10000-01-01" );
11671175
} );
11681176

11691177
// TODO: Fix this test so it isn't mysteriously flaky in Browserstack on certain OS/Browser combos

0 commit comments

Comments
 (0)