@@ -74,7 +74,11 @@ describe('uiCalendar', function () {
74
74
calendar :{
75
75
height : 200 ,
76
76
weekends : false ,
77
- defaultView : 'month'
77
+ defaultView : 'month' ,
78
+ dayClick : function ( ) { } ,
79
+ eventClick : function ( ) { } ,
80
+ eventDrop : function ( ) { } ,
81
+ eventResize : function ( ) { }
78
82
}
79
83
} ;
80
84
@@ -291,6 +295,87 @@ describe('uiCalendar', function () {
291
295
expect ( sourcesChanged ) . toBe ( 'removed' ) ;
292
296
} ) ;
293
297
298
+ it ( 'makes sure that dayClick is called in angular context' , inject ( function ( $timeout , $rootScope ) {
299
+ spyOn ( scope . uiConfig . calendar , 'dayClick' ) ;
300
+ spyOn ( $rootScope , '$apply' ) ;
301
+
302
+ var fullCalendarConfig = calendarCtrl . getFullCalendarConfig ( scope . uiConfig . calendar , { } ) ;
303
+
304
+ fullCalendarConfig . dayClick ( ) ;
305
+
306
+ $timeout . flush ( ) ;
307
+
308
+ expect ( $rootScope . $apply ) . toHaveBeenCalled ( ) ;
309
+ expect ( scope . uiConfig . calendar . dayClick ) . toHaveBeenCalled ( ) ;
310
+ } ) ) ;
311
+
312
+ it ( 'makes sure that eventClick is called in angular context' , inject ( function ( $timeout , $rootScope ) {
313
+ spyOn ( scope . uiConfig . calendar , 'eventClick' ) ;
314
+ spyOn ( $rootScope , '$apply' ) ;
315
+
316
+ var fullCalendarConfig = calendarCtrl . getFullCalendarConfig ( scope . uiConfig . calendar , { } ) ;
317
+
318
+ fullCalendarConfig . eventClick ( ) ;
319
+
320
+ $timeout . flush ( ) ;
321
+
322
+ expect ( $rootScope . $apply ) . toHaveBeenCalled ( ) ;
323
+ expect ( scope . uiConfig . calendar . eventClick ) . toHaveBeenCalled ( ) ;
324
+ } ) ) ;
325
+
326
+ it ( 'makes sure that eventDrop is called in angular context' , inject ( function ( $timeout , $rootScope ) {
327
+ spyOn ( scope . uiConfig . calendar , 'eventDrop' ) ;
328
+ spyOn ( $rootScope , '$apply' ) ;
329
+
330
+ var fullCalendarConfig = calendarCtrl . getFullCalendarConfig ( scope . uiConfig . calendar , { } ) ;
331
+
332
+ fullCalendarConfig . eventDrop ( ) ;
333
+
334
+ $timeout . flush ( ) ;
335
+
336
+ expect ( $rootScope . $apply ) . toHaveBeenCalled ( ) ;
337
+ expect ( scope . uiConfig . calendar . eventDrop ) . toHaveBeenCalled ( ) ;
338
+ } ) ) ;
339
+
340
+ it ( 'makes sure that eventResize is called in angular context' , inject ( function ( $timeout , $rootScope ) {
341
+ spyOn ( scope . uiConfig . calendar , 'eventResize' ) ;
342
+ spyOn ( $rootScope , '$apply' ) ;
343
+
344
+ var fullCalendarConfig = calendarCtrl . getFullCalendarConfig ( scope . uiConfig . calendar , { } ) ;
345
+
346
+ fullCalendarConfig . eventResize ( ) ;
347
+
348
+ $timeout . flush ( ) ;
349
+
350
+ expect ( $rootScope . $apply ) . toHaveBeenCalled ( ) ;
351
+ expect ( scope . uiConfig . calendar . eventResize ) . toHaveBeenCalled ( ) ;
352
+ } ) ) ;
353
+
354
+ it ( 'should not fail when addCommands is called with undefined settings ' , function ( ) {
355
+ expect ( calendarCtrl . addCommands ) . not . toThrow ( )
356
+ } ) ;
357
+
358
+ it ( 'makes sure that refetchEvents command is added on the configuration' , function ( ) {
359
+ calendarCtrl . addCommands ( scope . uiConfig . calendar , undefined ) ;
360
+
361
+ expect ( scope . uiConfig . calendar . refetchEvents ) . toBeDefined ( ) ;
362
+ } ) ;
363
+
364
+ it ( 'makes sure that fullCallendar is called with \'refetchEvents\' when refetchEvents command is called' , function ( ) {
365
+ var fakeCalendar = {
366
+ fullCalendar : function ( string ) {
367
+
368
+ }
369
+ }
370
+
371
+ spyOn ( fakeCalendar , 'fullCalendar' ) ;
372
+
373
+ calendarCtrl . addCommands ( scope . uiConfig . calendar , fakeCalendar ) ;
374
+
375
+ scope . uiConfig . calendar . refetchEvents ( )
376
+
377
+ expect ( fakeCalendar . fullCalendar ) . toHaveBeenCalledWith ( 'refetchEvents' ) ;
378
+ } ) ;
294
379
} ) ;
295
380
296
381
describe ( 'Testing the ability to add calendars to the scope' , function ( ) {
0 commit comments