@@ -1087,15 +1087,51 @@ describe('CalendarDayViewComponent component', () => {
1087
1087
fixture . componentInstance . ngOnInit ( ) ;
1088
1088
fixture . componentInstance . viewDate = new Date ( '2016-06-27' ) ;
1089
1089
fixture . componentInstance . ngOnChanges ( { viewDate : { } } ) ;
1090
- expect (
1091
- beforeViewRenderCalled . getCall ( 0 ) . args [ 0 ] . period . start instanceof Date
1092
- ) . to . equal ( true ) ;
1093
- expect (
1094
- beforeViewRenderCalled . getCall ( 0 ) . args [ 0 ] . period . end instanceof Date
1095
- ) . to . equal ( true ) ;
1096
- expect (
1097
- Array . isArray ( beforeViewRenderCalled . getCall ( 0 ) . args [ 0 ] . period . events )
1098
- ) . to . equal ( true ) ;
1090
+ const { period } = beforeViewRenderCalled . getCall ( 0 ) . args [ 0 ] ;
1091
+ expect ( period . start instanceof Date ) . to . equal ( true ) ;
1092
+ expect ( period . end instanceof Date ) . to . equal ( true ) ;
1093
+ expect ( Array . isArray ( period . events ) ) . to . equal ( true ) ;
1099
1094
fixture . destroy ( ) ;
1100
1095
} ) ;
1096
+
1097
+ it ( 'should expose the events on the beforeViewRender output' , ( ) => {
1098
+ const fixture : ComponentFixture <
1099
+ CalendarDayViewComponent
1100
+ > = TestBed . createComponent ( CalendarDayViewComponent ) ;
1101
+ const beforeViewRenderCalled = sinon . spy ( ) ;
1102
+ fixture . componentInstance . beforeViewRender
1103
+ . pipe ( take ( 1 ) )
1104
+ . subscribe ( beforeViewRenderCalled ) ;
1105
+ fixture . componentInstance . ngOnInit ( ) ;
1106
+ fixture . componentInstance . events = [
1107
+ {
1108
+ start : new Date ( '2016-05-30' ) ,
1109
+ end : new Date ( '2016-06-02' ) ,
1110
+ title : 'foo'
1111
+ } ,
1112
+ {
1113
+ start : new Date ( '2016-05-30' ) ,
1114
+ end : new Date ( '2016-06-02' ) ,
1115
+ title : 'bar' ,
1116
+ allDay : true
1117
+ }
1118
+ ] ;
1119
+ fixture . componentInstance . viewDate = new Date ( '2016-06-01' ) ;
1120
+ fixture . componentInstance . ngOnChanges ( { viewDate : { } } ) ;
1121
+ const { events, allDayEvents } = beforeViewRenderCalled . getCall (
1122
+ 0
1123
+ ) . args [ 0 ] . body ;
1124
+ expect ( events ) . to . deep . equal ( [
1125
+ {
1126
+ event : fixture . componentInstance . events [ 0 ] ,
1127
+ endsAfterDay : true ,
1128
+ startsBeforeDay : true ,
1129
+ height : 1439 ,
1130
+ top : 0 ,
1131
+ left : 0 ,
1132
+ width : 150
1133
+ }
1134
+ ] ) ;
1135
+ expect ( allDayEvents ) . to . deep . equal ( [ fixture . componentInstance . events [ 1 ] ] ) ;
1136
+ } ) ;
1101
1137
} ) ;
0 commit comments