mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Datepicker: Add min / max option tests
This commit is contained in:
parent
ea986f2808
commit
9428256ad3
@ -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 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user