@@ -485,6 +485,69 @@ describe('calendarWeekView component', () => {
485
485
} ) ;
486
486
} ) ;
487
487
488
+ it ( 'should resize events with no end date' , ( ) => {
489
+ const fixture : ComponentFixture <
490
+ CalendarWeekViewComponent
491
+ > = TestBed . createComponent ( CalendarWeekViewComponent ) ;
492
+ fixture . componentInstance . viewDate = new Date ( '2016-06-27' ) ;
493
+ fixture . componentInstance . events = [
494
+ {
495
+ title : 'foo' ,
496
+ color : { primary : '' , secondary : '' } ,
497
+ start : moment ( '2016-06-27' )
498
+ . add ( 4 , 'hours' )
499
+ . toDate ( ) ,
500
+ resizable : {
501
+ afterEnd : true
502
+ }
503
+ }
504
+ ] ;
505
+ fixture . componentInstance . ngOnChanges ( { viewDate : { } , events : { } } ) ;
506
+ fixture . detectChanges ( ) ;
507
+ document . body . appendChild ( fixture . nativeElement ) ;
508
+ const event : HTMLElement = fixture . nativeElement . querySelector (
509
+ '.cal-event-container'
510
+ ) ;
511
+ const dayWidth : number = event . parentElement . offsetWidth / 7 ;
512
+ const rect : ClientRect = event . getBoundingClientRect ( ) ;
513
+ let resizeEvent : CalendarEventTimesChangedEvent ;
514
+ fixture . componentInstance . eventTimesChanged . subscribe ( e => {
515
+ resizeEvent = e ;
516
+ } ) ;
517
+ triggerDomEvent ( 'mousedown' , document . body , {
518
+ clientX : rect . right ,
519
+ clientY : rect . top
520
+ } ) ;
521
+ fixture . detectChanges ( ) ;
522
+ triggerDomEvent ( 'mousemove' , document . body , {
523
+ clientX : rect . right + dayWidth ,
524
+ clientY : rect . top
525
+ } ) ;
526
+ fixture . detectChanges ( ) ;
527
+ expect ( Math . round ( event . getBoundingClientRect ( ) . left ) ) . to . equal (
528
+ Math . round ( rect . left )
529
+ ) ;
530
+ expect ( Math . round ( event . getBoundingClientRect ( ) . width ) ) . to . equal (
531
+ Math . round ( rect . width + dayWidth )
532
+ ) ;
533
+ triggerDomEvent ( 'mouseup' , document . body , {
534
+ clientX : rect . right + dayWidth ,
535
+ clientY : rect . top
536
+ } ) ;
537
+ fixture . detectChanges ( ) ;
538
+ fixture . destroy ( ) ;
539
+ expect ( resizeEvent ) . to . deep . equal ( {
540
+ event : fixture . componentInstance . events [ 0 ] ,
541
+ newStart : moment ( '2016-06-27' )
542
+ . add ( 4 , 'hours' )
543
+ . toDate ( ) ,
544
+ newEnd : moment ( '2016-06-27' )
545
+ . add ( 4 , 'hours' )
546
+ . add ( 1 , 'day' )
547
+ . toDate ( )
548
+ } ) ;
549
+ } ) ;
550
+
488
551
it ( 'should allow 2 events next to each other to be resized at the same time' , ( ) => {
489
552
const fixture : ComponentFixture <
490
553
CalendarWeekViewComponent
0 commit comments