mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Datepicker tests: Add open and close unit tests
This commit is contained in:
parent
258a3ff4e5
commit
6dfcd937f9
@ -14,15 +14,48 @@ test( "beforeOpen", function() {
|
||||
});
|
||||
|
||||
test( "close", function() {
|
||||
expect( 0 );
|
||||
expect( 4 );
|
||||
|
||||
var shouldFire,
|
||||
input = TestHelpers.datepicker.init( "#datepicker", {
|
||||
close: function() {
|
||||
ok( shouldFire, "close event fired" );
|
||||
}
|
||||
});
|
||||
|
||||
shouldFire = false;
|
||||
input.datepicker( "open" );
|
||||
shouldFire = true;
|
||||
input.datepicker( "close" );
|
||||
|
||||
shouldFire = false;
|
||||
input.datepicker( "open" );
|
||||
shouldFire = true;
|
||||
$( "body" ).trigger( "mousedown" );
|
||||
|
||||
shouldFire = false;
|
||||
input.datepicker( "open" );
|
||||
shouldFire = true;
|
||||
input.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
|
||||
|
||||
shouldFire = false;
|
||||
input.datepicker( "open" );
|
||||
shouldFire = true;
|
||||
input.datepicker( "widget" ).find( "tbody tr:first a:first" ).simulate( "mousedown" );
|
||||
});
|
||||
|
||||
test( "open", function() {
|
||||
expect( 0 );
|
||||
});
|
||||
expect( 2 );
|
||||
|
||||
test( "select", function() {
|
||||
expect( 0 );
|
||||
var input = TestHelpers.datepicker.init( "#datepicker", {
|
||||
open: function() {
|
||||
ok( true, "open event fired on open" );
|
||||
ok( widget.is( ":visible" ), "calendar open on open" );
|
||||
}
|
||||
}),
|
||||
widget = input.datepicker( "widget" );
|
||||
|
||||
input.datepicker( "open" );
|
||||
});
|
||||
|
||||
var selectedThis = null,
|
||||
|
@ -40,6 +40,25 @@ test( "widget", function() {
|
||||
actual.remove();
|
||||
});
|
||||
|
||||
test( "open / close", function() {
|
||||
expect( 7 );
|
||||
|
||||
var input = TestHelpers.datepicker.initNewInput({ show: false, hide: false }),
|
||||
calendar = input.datepicker( "widget" );
|
||||
|
||||
ok( calendar.is( ":hidden" ), "calendar hidden on init" );
|
||||
|
||||
input.datepicker( "open" );
|
||||
ok( calendar.is( ":visible" ), "open: calendar visible" );
|
||||
equal( calendar.attr( "aria-hidden" ), "false", "open: calendar aria-hidden" );
|
||||
equal( calendar.attr( "aria-expanded" ), "true", "close: calendar aria-expanded" );
|
||||
|
||||
input.datepicker( "close" );
|
||||
ok( !calendar.is( ":visible" ), "close: calendar hidden" );
|
||||
equal( calendar.attr( "aria-hidden" ), "true", "close: calendar aria-hidden" );
|
||||
equal( calendar.attr( "aria-expanded" ), "false", "close: calendar aria-expanded" );
|
||||
});
|
||||
|
||||
test( "value", function() {
|
||||
expect( 4 );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user