2016-05-22 15:18:28 +00:00
|
|
|
define( [
|
|
|
|
"jquery",
|
|
|
|
"./helper",
|
|
|
|
"ui/widgets/calendar"
|
|
|
|
], function( $, testHelper ) {
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
module( "calendar: events", {
|
|
|
|
setup: function() {
|
|
|
|
this.element = $( "#calendar" ).calendar();
|
|
|
|
}
|
|
|
|
} );
|
2016-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
asyncTest( "select", function() {
|
|
|
|
expect( 6 );
|
|
|
|
|
2016-05-22 19:58:20 +00:00
|
|
|
var that = this,
|
|
|
|
message, eventType;
|
|
|
|
|
|
|
|
this.element.calendar( {
|
|
|
|
select: function( event ) {
|
|
|
|
ok( true, "select event fired " + message );
|
|
|
|
equal(
|
|
|
|
event.type,
|
|
|
|
"calendarselect",
|
|
|
|
"select event " + message
|
|
|
|
);
|
|
|
|
equal(
|
|
|
|
event.originalEvent.type,
|
|
|
|
eventType,
|
|
|
|
"select originalEvent " + message
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} );
|
2016-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
function step1() {
|
|
|
|
setTimeout( function() {
|
|
|
|
eventType = "mousedown";
|
|
|
|
message = "on calendar button " + eventType;
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.find( "table button:eq(1)" ).simulate( eventType );
|
2016-05-22 15:18:28 +00:00
|
|
|
step2();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
function step2() {
|
|
|
|
setTimeout( function() {
|
|
|
|
eventType = "keydown";
|
|
|
|
message = "on calendar button " + eventType;
|
2016-05-22 19:58:20 +00:00
|
|
|
testHelper.focusGrid( that.element )
|
2016-05-22 15:18:28 +00:00
|
|
|
.simulate( eventType, { keyCode: $.ui.keyCode.END } )
|
|
|
|
.simulate( eventType, { keyCode: $.ui.keyCode.ENTER } );
|
|
|
|
step3();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// This should not trigger another event
|
|
|
|
function step3() {
|
|
|
|
setTimeout( function() {
|
2016-05-22 19:58:20 +00:00
|
|
|
that.element.calendar( "disable" );
|
|
|
|
that.element.find( "table button:eq(10)" ).simulate( "mousedown" );
|
2016-05-22 15:18:28 +00:00
|
|
|
start();
|
|
|
|
}, 50 );
|
|
|
|
}
|
|
|
|
|
|
|
|
step1();
|
|
|
|
} );
|
|
|
|
|
|
|
|
} );
|