diff options
author | Keith Wood <kbwood.au@gmail.com> | 2009-04-10 08:22:47 +0000 |
---|---|---|
committer | Keith Wood <kbwood.au@gmail.com> | 2009-04-10 08:22:47 +0000 |
commit | 4ae29ba06be7bae219eaf9b4d60a902003e7cf33 (patch) | |
tree | 78d939187d2dc5edce8236f6ab727b85aa75f897 | |
parent | c7a21a83ddd261f2a096f46664e048716e6f14ad (diff) | |
download | jquery-ui-4ae29ba06be7bae219eaf9b4d60a902003e7cf33.tar.gz jquery-ui-4ae29ba06be7bae219eaf9b4d60a902003e7cf33.zip |
Datepicker: Apply min/max settings on setDate
-rw-r--r-- | tests/unit/datepicker/datepicker_options.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/unit/datepicker/datepicker_options.js b/tests/unit/datepicker/datepicker_options.js index 6b82a8370..57c19d789 100644 --- a/tests/unit/datepicker/datepicker_options.js +++ b/tests/unit/datepicker/datepicker_options.js @@ -335,6 +335,22 @@ test('minMax', function() { simulate('keydown', {keyCode: $.simulate.VK_ENTER}); equalsDate(inp.datepicker('getDate'), date, 'Min/max - -1w, +1 M +10 D - ctrl+pgdn'); + // With existing date + inp = init('#inp'); + inp.val('06/04/2008').datepicker('option', {minDate: minDate}); + equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min'); + inp.datepicker('option', {minDate: null}).val('01/04/2008').datepicker('option', {minDate: minDate}); + equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - setDate < min'); + inp.datepicker('option', {minDate: null}).val('06/04/2008').datepicker('option', {maxDate: maxDate}); + equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate < max'); + inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {maxDate: maxDate}); + equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max'); + inp.datepicker('option', {maxDate: null}).val('01/04/2008').datepicker('option', {minDate: minDate, maxDate: maxDate}); + equalsDate(inp.datepicker('getDate'), minDate, 'Min/max - setDate < min'); + inp.datepicker('option', {maxDate: null}).val('06/04/2008').datepicker('option', {minDate: minDate, maxDate: maxDate}); + equalsDate(inp.datepicker('getDate'), new Date(2008, 6 - 1, 4), 'Min/max - setDate > min, < max'); + inp.datepicker('option', {maxDate: null}).val('01/04/2009').datepicker('option', {minDate: minDate, maxDate: maxDate}); + equalsDate(inp.datepicker('getDate'), maxDate, 'Min/max - setDate > max'); }); test('setDate', function() { @@ -380,6 +396,24 @@ test('setDate', function() { inp.datepicker('setDate', date1); equals(inp.val(), '06/04/2008', 'Set date alternate - 06/04/2008'); equals(alt.val(), '2008-06-04', 'Set date alternate - 2008-06-04'); + // With minimum/maximum + 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); + inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date2); + equalsDate(inp.datepicker('getDate'), date2, 'Set date min/max - setDate > min'); + inp.datepicker('setDate', date1); + equalsDate(inp.datepicker('getDate'), minDate, 'Set date min/max - setDate < min'); + inp.val('').datepicker('option', {maxDate: maxDate, minDate: null}).datepicker('setDate', date1); + equalsDate(inp.datepicker('getDate'), date1, 'Set date min/max - setDate < max'); + inp.datepicker('setDate', date2); + equalsDate(inp.datepicker('getDate'), maxDate, 'Set date min/max - setDate > max'); + inp.val('').datepicker('option', {minDate: minDate}).datepicker('setDate', date1); + 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'); }); test('altField', function() { |