]> source.dussan.org Git - jquery-ui.git/commitdiff
Calendar tests: Add select event unit tests
authorFelix Nagel <info@felixnagel.com>
Sun, 22 May 2016 15:18:28 +0000 (17:18 +0200)
committerFelix Nagel <info@felixnagel.com>
Thu, 29 Sep 2016 13:19:05 +0000 (15:19 +0200)
tests/unit/calendar/events.js

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..a8a0b38e0d10b02c04f85828413c4e6d4028d98e 100644 (file)
@@ -0,0 +1,61 @@
+define( [
+       "jquery",
+       "./helper",
+       "ui/widgets/calendar"
+], function( $, testHelper ) {
+
+module( "calendar: events" );
+
+asyncTest( "select", function() {
+       expect( 6 );
+
+       var message, eventType,
+               element = $( "#calendar" ).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
+                               );
+                       }
+               } );
+
+       function step1() {
+               setTimeout( function() {
+                       eventType = "mousedown";
+                       message = "on calendar button " + eventType;
+                       element.find( "table button:eq(1)" ).simulate( eventType );
+                       step2();
+               }, 50 );
+       }
+
+       function step2() {
+               setTimeout( function() {
+                       eventType = "keydown";
+                       message = "on calendar button " + eventType;
+                       testHelper.focusGrid( element )
+                               .simulate( eventType, { keyCode: $.ui.keyCode.END } )
+                               .simulate( eventType, { keyCode: $.ui.keyCode.ENTER } );
+                       step3();
+               }, 50 );
+       }
+
+       // This should not trigger another event
+       function step3() {
+               setTimeout( function() {
+                       element.calendar( "disable" );
+                       element.find( "table button:eq(10)" ).simulate( "mousedown" );
+                       start();
+               }, 50 );
+       }
+
+       step1();
+} );
+
+} );