Skip to content
Permalink
Browse files

Dev: fix the datepicker test suite and jshint everything. Fixes #8804…

… - Dev: re-enable the datepicker test suite
  • Loading branch information...
mikesherov committed Nov 9, 2012
1 parent 543abc9 commit 254f2b3698265bdcb7daa85f8c7e2c27192cd090
@@ -13,7 +13,7 @@ var versions = {
"Autocomplete": "autocomplete/autocomplete.html",
"Button": "button/button.html",
"Core": "core/core.html",
//"Datepicker": "datepicker/datepicker.html",
"Datepicker": "datepicker/datepicker.html",
"Dialog": "dialog/dialog.html",
"Draggable": "draggable/draggable.html",
"Droppable": "droppable/droppable.html",
@@ -281,13 +281,13 @@ grunt.initConfig({
files: grunt.file.expandFiles( "tests/unit/**/*.html" ).filter(function( file ) {
// disabling everything that doesn't (quite) work with PhantomJS for now
// TODO except for all|index|test, try to include more as we go
return !( /(all|all-active|index|test|dialog|slider|datepicker|tabs|tooltip)\.html$/ ).test( file );
return !( /(all|all-active|index|test|dialog|slider|tabs|tooltip)\.html$/ ).test( file );
})
},
lint: {
ui: grunt.file.expandFiles( "ui/*.js" ).filter(function( file ) {
// TODO remove items from this list once rewritten
return !( /(mouse|datepicker)\.js$/ ).test( file );
return !( /(mouse)\.js$/ ).test( file );
}),
grunt: [ "grunt.js", "build/**/*.js" ],
tests: "tests/unit/**/*.js"
@@ -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",
@@ -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>
@@ -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);
@@ -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);

This file was deleted.

0 comments on commit 254f2b3

Please sign in to comment.
You can’t perform that action at this time.