33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6- import { getDefaultEventObject , mapEventComponentToEventObject } from " ../../../../src/models/event.js" ;
6+ import { copyCalendarObjectInstanceIntoEventComponent , getDefaultEventObject , mapEventComponentToEventObject } from ' ../../../../src/models/event.js'
77import { getDateFromDateTimeValue } from '../../../../src/utils/date.js'
88import { getHexForColorName } from '../../../../src/utils/color.js'
99import { mapAlarmComponentToAlarmObject } from '../../../../src/models/alarm.js'
@@ -62,6 +62,7 @@ describe('Test suite: Event model (models/event.js)', () => {
6262 customColor : null ,
6363 categories : [ ] ,
6464 attachments : [ ] ,
65+ invitationForwarding : 'TRUE' ,
6566 } )
6667
6768 expect ( getDefaultRecurrenceRuleObject ) . toHaveBeenCalledTimes ( 1 )
@@ -104,6 +105,7 @@ describe('Test suite: Event model (models/event.js)', () => {
104105 customColor : null ,
105106 categories : [ ] ,
106107 attachments : [ ] ,
108+ invitationForwarding : 'TRUE' ,
107109 otherProp : 'foo' ,
108110 } )
109111
@@ -154,6 +156,7 @@ describe('Test suite: Event model (models/event.js)', () => {
154156 customColor : null ,
155157 categories : [ ] ,
156158 attachments : [ ] ,
159+ invitationForwarding : 'TRUE' ,
157160 } )
158161
159162 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -221,7 +224,8 @@ describe('Test suite: Event model (models/event.js)', () => {
221224 alarms : [ ] ,
222225 customColor : null ,
223226 categories : [ ] ,
224- attachments : [ ]
227+ attachments : [ ] ,
228+ invitationForwarding : 'TRUE' ,
225229 } )
226230
227231 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -289,6 +293,7 @@ describe('Test suite: Event model (models/event.js)', () => {
289293 customColor : null ,
290294 categories : [ ] ,
291295 attachments : [ ] ,
296+ invitationForwarding : 'TRUE' ,
292297 } )
293298
294299 const alarms = eventComponent . getAlarmList ( )
@@ -343,6 +348,7 @@ describe('Test suite: Event model (models/event.js)', () => {
343348 customColor : null ,
344349 categories : [ 'BUSINESS' , 'HUMAN RESOURCES' ] ,
345350 attachments : [ ] ,
351+ invitationForwarding : 'TRUE' ,
346352 } )
347353
348354 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -399,6 +405,7 @@ describe('Test suite: Event model (models/event.js)', () => {
399405 customColor : '#eeffee' ,
400406 categories : [ ] ,
401407 attachments : [ ] ,
408+ invitationForwarding : 'TRUE' ,
402409 } )
403410
404411 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -458,6 +465,7 @@ describe('Test suite: Event model (models/event.js)', () => {
458465 customColor : null ,
459466 categories : [ ] ,
460467 attachments : [ ] ,
468+ invitationForwarding : 'TRUE' ,
461469 } )
462470
463471 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -514,6 +522,7 @@ describe('Test suite: Event model (models/event.js)', () => {
514522 customColor : null ,
515523 categories : [ ] ,
516524 attachments : [ ] ,
525+ invitationForwarding : 'TRUE' ,
517526 } )
518527
519528 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -567,6 +576,7 @@ describe('Test suite: Event model (models/event.js)', () => {
567576 customColor : null ,
568577 categories : [ ] ,
569578 attachments : [ ] ,
579+ invitationForwarding : 'TRUE' ,
570580 } )
571581
572582 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -620,6 +630,7 @@ describe('Test suite: Event model (models/event.js)', () => {
620630 customColor : null ,
621631 categories : [ ] ,
622632 attachments : [ ] ,
633+ invitationForwarding : 'TRUE' ,
623634 } )
624635
625636 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -677,6 +688,7 @@ describe('Test suite: Event model (models/event.js)', () => {
677688 customColor : null ,
678689 categories : [ ] ,
679690 attachments : [ ] ,
691+ invitationForwarding : 'TRUE' ,
680692 } )
681693
682694 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -733,6 +745,7 @@ describe('Test suite: Event model (models/event.js)', () => {
733745 customColor : null ,
734746 categories : [ ] ,
735747 attachments : [ ] ,
748+ invitationForwarding : 'TRUE' ,
736749 } )
737750
738751 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -787,6 +800,7 @@ describe('Test suite: Event model (models/event.js)', () => {
787800 customColor : null ,
788801 categories : [ ] ,
789802 attachments : [ ] ,
803+ invitationForwarding : 'TRUE' ,
790804 } )
791805
792806 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -844,6 +858,7 @@ describe('Test suite: Event model (models/event.js)', () => {
844858 customColor : null ,
845859 categories : [ ] ,
846860 attachments : [ ] ,
861+ invitationForwarding : 'TRUE' ,
847862 } )
848863
849864 expect ( getDateFromDateTimeValue ) . toHaveBeenCalledTimes ( 2 )
@@ -858,4 +873,55 @@ describe('Test suite: Event model (models/event.js)', () => {
858873
859874 expect ( getDefaultRecurrenceRuleObject ) . toHaveBeenCalledTimes ( 1 )
860875 } )
876+
877+ it ( 'should default invitation forwarding to TRUE' , ( ) => {
878+ getDefaultRecurrenceRuleObject
879+ . mockReturnValueOnce ( {
880+ defaultRecurrenceObject : true ,
881+ } )
882+
883+ expect ( getDefaultEventObject ( ) . invitationForwarding ) . toEqual ( 'TRUE' )
884+ } )
885+
886+ it ( 'should map an event component custom invitation forwarding property' , ( ) => {
887+ const recurrenceId = DateTimeValue . fromJSDate ( new Date ( Date . UTC ( 2016 , 7 , 16 , 7 , 0 , 0 ) ) , true )
888+ const eventComponent = getEventComponentFromAsset ( 'vcalendars/vcalendar-event-timed' , recurrenceId )
889+ eventComponent . updatePropertyWithValue ( 'X-NC-INVITATION-FORWARDING' , 'FALSE' )
890+
891+ const mockDate1 = new Date ( )
892+ const mockDate2 = new Date ( )
893+ getDateFromDateTimeValue
894+ . mockReturnValueOnce ( mockDate1 )
895+ . mockReturnValueOnce ( mockDate2 )
896+
897+ getDefaultRecurrenceRuleObject
898+ . mockReturnValueOnce ( {
899+ defaultRecurrenceObject : true ,
900+ } )
901+
902+ expect ( mapEventComponentToEventObject ( eventComponent ) . invitationForwarding ) . toEqual ( 'FALSE' )
903+ } )
904+
905+ it ( 'should copy the custom invitation forwarding property into a new event component' , ( ) => {
906+ const recurrenceId = DateTimeValue . fromJSDate ( new Date ( Date . UTC ( 2016 , 7 , 16 , 7 , 0 , 0 ) ) , true )
907+ const sourceEventComponent = getEventComponentFromAsset ( 'vcalendars/vcalendar-event-timed' , recurrenceId )
908+ const targetEventComponent = getEventComponentFromAsset ( 'vcalendars/vcalendar-event-timed' , recurrenceId )
909+ sourceEventComponent . updatePropertyWithValue ( 'X-NC-INVITATION-FORWARDING' , 'FALSE' )
910+
911+ const eventObject = getDefaultEventObject ( {
912+ eventComponent : sourceEventComponent ,
913+ title : sourceEventComponent . title ,
914+ location : sourceEventComponent . location ,
915+ description : sourceEventComponent . description ,
916+ accessClass : sourceEventComponent . accessClass ,
917+ status : sourceEventComponent . status ,
918+ timeTransparency : sourceEventComponent . timeTransparency ,
919+ invitationForwarding : 'FALSE' ,
920+ } )
921+
922+ copyCalendarObjectInstanceIntoEventComponent ( eventObject , targetEventComponent )
923+
924+ expect ( targetEventComponent . hasProperty ( 'X-NC-INVITATION-FORWARDING' ) ) . toBe ( true )
925+ expect ( targetEventComponent . getFirstPropertyFirstValue ( 'X-NC-INVITATION-FORWARDING' ) ) . toBe ( 'FALSE' )
926+ } )
861927} )
0 commit comments