@@ -90,7 +90,8 @@ describe('calendarMonthView component', () => {
90
90
fixture . componentInstance . ngOnChanges ( { viewDate : { } } ) ;
91
91
fixture . detectChanges ( ) ;
92
92
fixture . componentInstance . columnHeaderClicked . subscribe ( val => {
93
- expect ( val ) . to . equal ( 0 ) ;
93
+ expect ( val . isoDayNumber ) . to . equal ( 0 ) ;
94
+ expect ( val . sourceEvent instanceof MouseEvent ) . to . be . true ;
94
95
done ( ) ;
95
96
} ) ;
96
97
fixture . nativeElement . querySelector ( '.cal-header .cal-cell' ) . click ( ) ;
@@ -385,9 +386,13 @@ describe('calendarMonthView component', () => {
385
386
expect ( action . innerHTML ) . to . equal ( '<i class="fa fa-fw fa-times"></i>' ) ;
386
387
expect ( action . classList . contains ( 'foo' ) ) . to . equal ( true ) ;
387
388
action . click ( ) ;
388
- expect (
389
- fixture . componentInstance . events [ 0 ] . actions [ 0 ] . onClick
390
- ) . to . have . been . calledWith ( { event : fixture . componentInstance . events [ 0 ] } ) ;
389
+ const actionSpy = fixture . componentInstance . events [ 0 ] . actions [ 0 ]
390
+ . onClick as sinon . SinonSpy ;
391
+ expect ( actionSpy . getCall ( 0 ) . args [ 0 ] . event ) . to . equal (
392
+ fixture . componentInstance . events [ 0 ]
393
+ ) ;
394
+ expect ( actionSpy . getCall ( 0 ) . args [ 0 ] . sourceEvent instanceof MouseEvent ) . to . be
395
+ . true ;
391
396
} ) ;
392
397
393
398
it ( 'should add event actions to the active day events on enter keypress' , ( ) => {
@@ -421,10 +426,13 @@ describe('calendarMonthView component', () => {
421
426
) ;
422
427
expect ( action . innerHTML ) . to . equal ( '<i class="fa fa-fw fa-times"></i>' ) ;
423
428
expect ( action . classList . contains ( 'foo' ) ) . to . equal ( true ) ;
424
- triggerDomEvent ( 'keydown' , action , { keyCode : 13 } ) ;
429
+ const sourceEvent = triggerDomEvent ( 'keydown' , action , { keyCode : 13 } ) ;
425
430
expect (
426
431
fixture . componentInstance . events [ 0 ] . actions [ 0 ] . onClick
427
- ) . to . have . been . calledWith ( { event : fixture . componentInstance . events [ 0 ] } ) ;
432
+ ) . to . have . been . calledWith ( {
433
+ event : fixture . componentInstance . events [ 0 ] ,
434
+ sourceEvent
435
+ } ) ;
428
436
} ) ;
429
437
430
438
it ( 'should call the event clicked callback' , ( ) => {
@@ -451,7 +459,10 @@ describe('calendarMonthView component', () => {
451
459
) ;
452
460
expect ( title . innerHTML ) . to . equal ( '<span>foo</span>' ) ;
453
461
fixture . componentInstance . eventClicked . subscribe ( val => {
454
- expect ( val ) . to . deep . equal ( { event : fixture . componentInstance . events [ 0 ] } ) ;
462
+ expect ( val ) . to . deep . equal ( {
463
+ event : fixture . componentInstance . events [ 0 ] ,
464
+ sourceEvent : window [ 'event' ]
465
+ } ) ;
455
466
} ) ;
456
467
title . click ( ) ;
457
468
} ) ;
@@ -480,7 +491,10 @@ describe('calendarMonthView component', () => {
480
491
) ;
481
492
expect ( title . innerHTML ) . to . equal ( '<span>foo</span>' ) ;
482
493
fixture . componentInstance . eventClicked . subscribe ( val => {
483
- expect ( val ) . to . deep . equal ( { event : fixture . componentInstance . events [ 0 ] } ) ;
494
+ expect ( val ) . to . deep . equal ( {
495
+ event : fixture . componentInstance . events [ 0 ] ,
496
+ sourceEvent : window [ 'event' ]
497
+ } ) ;
484
498
} ) ;
485
499
triggerDomEvent ( 'keydown' , title , { keyCode : 13 } ) ;
486
500
} ) ;
@@ -920,10 +934,10 @@ describe('calendarMonthView component', () => {
920
934
'.cal-days .cal-cell-row .cal-cell:nth-child(4) .cal-events .cal-event'
921
935
) ;
922
936
event . click ( ) ;
923
- fixture . destroy ( ) ;
924
- expect ( eventClickedEvent ) . to . deep . equal ( {
925
- event : fixture . componentInstance . events [ 0 ]
926
- } ) ;
937
+ expect ( eventClickedEvent . event ) . to . equal (
938
+ fixture . componentInstance . events [ 0 ]
939
+ ) ;
940
+ expect ( eventClickedEvent . sourceEvent instanceof MouseEvent ) . to . be . true ;
927
941
expect ( dayClickedFired ) . to . equal ( false ) ;
928
942
} ) ;
929
943
0 commit comments