@@ -266,6 +266,7 @@ describe('CalendarDayViewComponent component', () => {
266
266
fixture . detectChanges ( ) ;
267
267
document . body . appendChild ( fixture . nativeElement ) ;
268
268
const event : HTMLElement = fixture . nativeElement . querySelector ( '.cal-event' ) ;
269
+ event . style . position = 'absolute' ;
269
270
const rect : ClientRect = event . getBoundingClientRect ( ) ;
270
271
let resizeEvent : CalendarEventTimesChangedEvent ;
271
272
fixture . componentInstance . eventTimesChanged . subscribe ( event => {
@@ -303,6 +304,7 @@ describe('CalendarDayViewComponent component', () => {
303
304
fixture . detectChanges ( ) ;
304
305
document . body . appendChild ( fixture . nativeElement ) ;
305
306
const event : HTMLElement = fixture . nativeElement . querySelector ( '.cal-event' ) ;
307
+ event . style . position = 'absolute' ;
306
308
const rect : ClientRect = event . getBoundingClientRect ( ) ;
307
309
let resizeEvent : CalendarEventTimesChangedEvent ;
308
310
fixture . componentInstance . eventTimesChanged . subscribe ( event => {
@@ -443,4 +445,37 @@ describe('CalendarDayViewComponent component', () => {
443
445
fixture . destroy ( ) ;
444
446
} ) ;
445
447
448
+ it ( 'should not allow events to be resized outside of the container' , ( ) => {
449
+ const fixture : ComponentFixture < CalendarDayViewComponent > = TestBed . createComponent ( CalendarDayViewComponent ) ;
450
+ fixture . componentInstance . viewDate = new Date ( '2016-06-27' ) ;
451
+ fixture . componentInstance . events = [ {
452
+ title : 'foo' ,
453
+ color : { primary : '' , secondary : '' } ,
454
+ start : moment ( '2016-06-27' ) . add ( 1 , 'hours' ) . toDate ( ) ,
455
+ end : moment ( '2016-06-27' ) . add ( 6 , 'hours' ) . toDate ( ) ,
456
+ resizable : {
457
+ beforeStart : true
458
+ }
459
+ } ] ;
460
+ fixture . componentInstance . ngOnChanges ( { viewDate : { } , events : { } } ) ;
461
+ fixture . detectChanges ( ) ;
462
+ document . body . appendChild ( fixture . nativeElement ) ;
463
+ const event : HTMLElement = fixture . nativeElement . querySelector ( '.cal-event' ) ;
464
+ event . style . position = 'absolute' ;
465
+ const rect : ClientRect = event . getBoundingClientRect ( ) ;
466
+ triggerDomEvent ( 'mousedown' , document . body , { clientY : rect . top , clientX : rect . left + 10 } ) ;
467
+ fixture . detectChanges ( ) ;
468
+ triggerDomEvent ( 'mousemove' , document . body , { clientY : rect . top - 60 , clientX : rect . left + 10 } ) ;
469
+ fixture . detectChanges ( ) ;
470
+ expect ( event . getBoundingClientRect ( ) . top ) . to . equal ( rect . top - 60 ) ;
471
+ expect ( event . getBoundingClientRect ( ) . height ) . to . equal ( rect . height + 60 ) ;
472
+ triggerDomEvent ( 'mousemove' , document . body , { clientY : rect . top - 120 , clientX : rect . left + 10 } ) ;
473
+ fixture . detectChanges ( ) ;
474
+ expect ( event . getBoundingClientRect ( ) . top ) . to . equal ( rect . top - 60 ) ;
475
+ expect ( event . getBoundingClientRect ( ) . height ) . to . equal ( rect . height + 60 ) ;
476
+ triggerDomEvent ( 'mouseup' , document . body , { clientY : rect . top - 60 , clientX : rect . left + 10 } ) ;
477
+ fixture . detectChanges ( ) ;
478
+ fixture . destroy ( ) ;
479
+ } ) ;
480
+
446
481
} ) ;
0 commit comments