Skip to content

Commit d1152a3

Browse files
committed
Calendar tests: Add select event unit tests
1 parent ea6c475 commit d1152a3

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

tests/unit/calendar/events.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
define( [
2+
"jquery",
3+
"./helper",
4+
"ui/widgets/calendar"
5+
], function( $, testHelper ) {
6+
7+
module( "calendar: events" );
8+
9+
asyncTest( "select", function() {
10+
expect( 6 );
11+
12+
var message, eventType,
13+
element = $( "#calendar" ).calendar( {
14+
select: function( event ) {
15+
ok( true, "select event fired " + message );
16+
equal(
17+
event.type,
18+
"calendarselect",
19+
"select event " + message
20+
);
21+
equal(
22+
event.originalEvent.type,
23+
eventType,
24+
"select originalEvent " + message
25+
);
26+
}
27+
} );
28+
29+
function step1() {
30+
setTimeout( function() {
31+
eventType = "mousedown";
32+
message = "on calendar button " + eventType;
33+
element.find( "table button:eq(1)" ).simulate( eventType );
34+
step2();
35+
}, 50 );
36+
}
37+
38+
function step2() {
39+
setTimeout( function() {
40+
eventType = "keydown";
41+
message = "on calendar button " + eventType;
42+
testHelper.focusGrid( element )
43+
.simulate( eventType, { keyCode: $.ui.keyCode.END } )
44+
.simulate( eventType, { keyCode: $.ui.keyCode.ENTER } );
45+
step3();
46+
}, 50 );
47+
}
48+
49+
// This should not trigger another event
50+
function step3() {
51+
setTimeout( function() {
52+
element.calendar( "disable" );
53+
element.find( "table button:eq(10)" ).simulate( "mousedown" );
54+
start();
55+
}, 50 );
56+
}
57+
58+
step1();
59+
} );
60+
61+
} );

0 commit comments

Comments
 (0)