From: Felix Nagel Date: Sun, 29 May 2016 00:09:13 +0000 (+0200) Subject: Datepicker: Add min / max option tests X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9428256ad3036408d129b6501b072192841d98eb;p=jquery-ui.git Datepicker: Add min / max option tests --- diff --git a/tests/unit/datepicker/options.js b/tests/unit/datepicker/options.js index f04b3fb4d..e5b142acc 100644 --- a/tests/unit/datepicker/options.js +++ b/tests/unit/datepicker/options.js @@ -48,6 +48,45 @@ test( "appendTo", function() { equal( container, detached[ 0 ], "detached DOM element" ); } ); +test( "min / max", function( assert ) { + expect( 10 ); + + var min, max; + + this.element.datepicker( "option", { min: "10/20/08", max: "10/25/08" } ); + assert.dateEqual( this.element.datepicker( "option", "min" ), new Date( 2008, 10 - 1, 20 ), "Set min option as string" ); + assert.dateEqual( this.element.datepicker( "option", "max" ), new Date( 2008, 10 - 1, 25 ), "Set max option as string" ); + + min = new Date( 2009, 10 - 1, 20 ); + max = new Date( 2009, 10 - 1, 25 ); + this.element.datepicker( "option", { min: min, max: max } ); + assert.dateEqual( this.element.datepicker( "option", "min" ), min, "Set min option as date object" ); + assert.dateEqual( this.element.datepicker( "option", "max" ), max, "Set max option as date object" ); + + this.element + .datepicker( "destroy" ) + .attr( "min", "2010-10-20" ) + .attr( "max", "2010-10-25" ) + .datepicker(); + assert.dateEqual( this.element.datepicker( "option", "min" ), new Date( 2010, 10 - 1, 20 ), "Set min option as attribute" ); + assert.dateEqual( this.element.datepicker( "option", "max" ), new Date( 2010, 10 - 1, 25 ), "Set max option as attribute" ); + + min = new Date( 2011, 10 - 1, 20 ); + max = new Date( 2011, 10 - 1, 25 ); + this.element + .datepicker( "destroy" ) + .datepicker( { min: min, max: max } ); + assert.dateEqual( this.element.datepicker( "option", "min" ), new Date( 2011, 10 - 1, 20 ), "Set min option as date object on init" ); + assert.dateEqual( this.element.datepicker( "option", "max" ), new Date( 2011, 10 - 1, 25 ), "Set max option as date object on init" ); + + this.element + .datepicker( "destroy" ) + .datepicker( { min: "10/20/12", max: "10/25/12" } ); + assert.dateEqual( this.element.datepicker( "option", "min" ), new Date( 2012, 10 - 1, 20 ), "Set min option as string on init" ); + assert.dateEqual( this.element.datepicker( "option", "max" ), new Date( 2012, 10 - 1, 25 ), "Set max option as string on init" ); + +} ); + test( "Pass-through options", function() { expect( 11 );