@@ -26,11 +26,14 @@ describe("CalendarEventBuilder", () => {
2626 } )
2727 . build ( ) ;
2828
29- expect ( event . bookerUrl ) . toBe ( "https://cal.com/user/test-slug" ) ;
30- expect ( event . title ) . toBe ( "Test Event" ) ;
31- expect ( event . startTime ) . toBe ( mockStartTime ) ;
32- expect ( event . endTime ) . toBe ( mockEndTime ) ;
33- expect ( event . additionalNotes ) . toBe ( "Some notes" ) ;
29+ expect ( event ) . not . toBeNull ( ) ;
30+ if ( event ) {
31+ expect ( event . bookerUrl ) . toBe ( "https://cal.com/user/test-slug" ) ;
32+ expect ( event . title ) . toBe ( "Test Event" ) ;
33+ expect ( event . startTime ) . toBe ( mockStartTime ) ;
34+ expect ( event . endTime ) . toBe ( mockEndTime ) ;
35+ expect ( event . additionalNotes ) . toBe ( "Some notes" ) ;
36+ }
3437 } ) ;
3538
3639 it ( "should create an event with event type details" , ( ) => {
@@ -50,11 +53,14 @@ describe("CalendarEventBuilder", () => {
5053 } )
5154 . build ( ) ;
5255
53- expect ( event . type ) . toBe ( "test-slug" ) ;
54- expect ( event . description ) . toBe ( "Test description" ) ;
55- expect ( event . eventTypeId ) . toBe ( 123 ) ;
56- expect ( event . hideCalendarNotes ) . toBe ( true ) ;
57- expect ( event . hideCalendarEventDetails ) . toBe ( false ) ;
56+ expect ( event ) . not . toBeNull ( ) ;
57+ if ( event ) {
58+ expect ( event . type ) . toBe ( "test-slug" ) ;
59+ expect ( event . description ) . toBe ( "Test description" ) ;
60+ expect ( event . eventTypeId ) . toBe ( 123 ) ;
61+ expect ( event . hideCalendarNotes ) . toBe ( true ) ;
62+ expect ( event . hideCalendarEventDetails ) . toBe ( false ) ;
63+ }
5864 } ) ;
5965
6066 it ( "should create an event with organizer details" , ( ) => {
@@ -82,17 +88,20 @@ describe("CalendarEventBuilder", () => {
8288 } )
8389 . build ( ) ;
8490
85- expect ( event . organizer ) . toEqual ( {
86- id : 456 ,
87- name : "John Doe" ,
88- email : "john@example.com" ,
89- username : "johndoe" ,
90- timeZone : "America/New_York" ,
91- language : {
92- translate : mockTranslate ,
93- locale : "en" ,
94- } ,
95- } ) ;
91+ expect ( event ) . not . toBeNull ( ) ;
92+ if ( event ) {
93+ expect ( event . organizer ) . toEqual ( {
94+ id : 456 ,
95+ name : "John Doe" ,
96+ email : "john@example.com" ,
97+ username : "johndoe" ,
98+ timeZone : "America/New_York" ,
99+ language : {
100+ translate : mockTranslate ,
101+ locale : "en" ,
102+ } ,
103+ } ) ;
104+ }
96105 } ) ;
97106
98107 it ( "should handle nameless organizer" , ( ) => {
@@ -119,7 +128,10 @@ describe("CalendarEventBuilder", () => {
119128 } )
120129 . build ( ) ;
121130
122- expect ( event . organizer . name ) . toBe ( "Nameless" ) ;
131+ expect ( event ) . not . toBeNull ( ) ;
132+ if ( event ) {
133+ expect ( event . organizer . name ) . toBe ( "Nameless" ) ;
134+ }
123135 } ) ;
124136
125137 it ( "should create an event with attendees" , ( ) => {
@@ -158,7 +170,10 @@ describe("CalendarEventBuilder", () => {
158170 . withAttendees ( attendees )
159171 . build ( ) ;
160172
161- expect ( event . attendees ) . toEqual ( attendees ) ;
173+ expect ( event ) . not . toBeNull ( ) ;
174+ if ( event ) {
175+ expect ( event . attendees ) . toEqual ( attendees ) ;
176+ }
162177 } ) ;
163178
164179 it ( "should create an event with metadata and responses" , ( ) => {
@@ -192,10 +207,13 @@ describe("CalendarEventBuilder", () => {
192207 } )
193208 . build ( ) ;
194209
195- expect ( event . additionalNotes ) . toBe ( "Some notes" ) ;
196- expect ( event . customInputs ) . toEqual ( customInputs ) ;
197- expect ( event . responses ) . toEqual ( responses ) ;
198- expect ( event . userFieldsResponses ) . toEqual ( userFieldsResponses ) ;
210+ expect ( event ) . not . toBeNull ( ) ;
211+ if ( event ) {
212+ expect ( event . additionalNotes ) . toBe ( "Some notes" ) ;
213+ expect ( event . customInputs ) . toEqual ( customInputs ) ;
214+ expect ( event . responses ) . toEqual ( responses ) ;
215+ expect ( event . userFieldsResponses ) . toEqual ( userFieldsResponses ) ;
216+ }
199217 } ) ;
200218
201219 it ( "should create an event with location" , ( ) => {
@@ -216,8 +234,11 @@ describe("CalendarEventBuilder", () => {
216234 } )
217235 . build ( ) ;
218236
219- expect ( event . location ) . toBe ( "Conference Room A" ) ;
220- expect ( event . conferenceCredentialId ) . toBe ( 789 ) ;
237+ expect ( event ) . not . toBeNull ( ) ;
238+ if ( event ) {
239+ expect ( event . location ) . toBe ( "Conference Room A" ) ;
240+ expect ( event . conferenceCredentialId ) . toBe ( 789 ) ;
241+ }
221242 } ) ;
222243
223244 it ( "should create an event with destination calendar" , ( ) => {
@@ -229,6 +250,8 @@ describe("CalendarEventBuilder", () => {
229250 userId : null ,
230251 eventTypeId : null ,
231252 credentialId : null ,
253+ createdAt : null ,
254+ updatedAt : null ,
232255 delegationCredentialId : null ,
233256 domainWideDelegationCredentialId : null ,
234257 } ;
@@ -247,7 +270,10 @@ describe("CalendarEventBuilder", () => {
247270 . withDestinationCalendar ( [ destinationCalendar ] )
248271 . build ( ) ;
249272
250- expect ( event . destinationCalendar ) . toEqual ( [ destinationCalendar ] ) ;
273+ expect ( event ) . not . toBeNull ( ) ;
274+ if ( event ) {
275+ expect ( event . destinationCalendar ) . toEqual ( [ destinationCalendar ] ) ;
276+ }
251277 } ) ;
252278
253279 it ( "should create an event with identifiers" , ( ) => {
@@ -268,8 +294,11 @@ describe("CalendarEventBuilder", () => {
268294 } )
269295 . build ( ) ;
270296
271- expect ( event . iCalUID ) . toBe ( "ical-123" ) ;
272- expect ( event . iCalSequence ) . toBe ( 2 ) ;
297+ expect ( event ) . not . toBeNull ( ) ;
298+ if ( event ) {
299+ expect ( event . iCalUID ) . toBe ( "ical-123" ) ;
300+ expect ( event . iCalSequence ) . toBe ( 2 ) ;
301+ }
273302 } ) ;
274303
275304 it ( "should create an event with confirmation settings" , ( ) => {
@@ -290,8 +319,11 @@ describe("CalendarEventBuilder", () => {
290319 } )
291320 . build ( ) ;
292321
293- expect ( event . requiresConfirmation ) . toBe ( true ) ;
294- expect ( event . oneTimePassword ) . toBeUndefined ( ) ;
322+ expect ( event ) . not . toBeNull ( ) ;
323+ if ( event ) {
324+ expect ( event . requiresConfirmation ) . toBe ( true ) ;
325+ expect ( event . oneTimePassword ) . toBeUndefined ( ) ;
326+ }
295327 } ) ;
296328
297329 it ( "should set oneTimePassword to null when isConfirmedByDefault is true" , ( ) => {
@@ -312,8 +344,11 @@ describe("CalendarEventBuilder", () => {
312344 } )
313345 . build ( ) ;
314346
315- expect ( event . requiresConfirmation ) . toBe ( true ) ;
316- expect ( event . oneTimePassword ) . toBeNull ( ) ;
347+ expect ( event ) . not . toBeNull ( ) ;
348+ if ( event ) {
349+ expect ( event . requiresConfirmation ) . toBe ( true ) ;
350+ expect ( event . oneTimePassword ) . toBeNull ( ) ;
351+ }
317352 } ) ;
318353
319354 it ( "should create an event with platform variables" , ( ) => {
@@ -336,10 +371,13 @@ describe("CalendarEventBuilder", () => {
336371 } )
337372 . build ( ) ;
338373
339- expect ( event . platformClientId ) . toBe ( "client-123" ) ;
340- expect ( event . platformRescheduleUrl ) . toBe ( "https://platform.com/reschedule" ) ;
341- expect ( event . platformCancelUrl ) . toBe ( "https://platform.com/cancel" ) ;
342- expect ( event . platformBookingUrl ) . toBe ( "https://platform.com/booking" ) ;
374+ expect ( event ) . not . toBeNull ( ) ;
375+ if ( event ) {
376+ expect ( event . platformClientId ) . toBe ( "client-123" ) ;
377+ expect ( event . platformRescheduleUrl ) . toBe ( "https://platform.com/reschedule" ) ;
378+ expect ( event . platformCancelUrl ) . toBe ( "https://platform.com/cancel" ) ;
379+ expect ( event . platformBookingUrl ) . toBe ( "https://platform.com/booking" ) ;
380+ }
343381 } ) ;
344382
345383 it ( "should create an event with apps status" , ( ) => {
@@ -376,7 +414,10 @@ describe("CalendarEventBuilder", () => {
376414 . withAppsStatus ( appsStatus )
377415 . build ( ) ;
378416
379- expect ( event . appsStatus ) . toEqual ( appsStatus ) ;
417+ expect ( event ) . not . toBeNull ( ) ;
418+ if ( event ) {
419+ expect ( event . appsStatus ) . toEqual ( appsStatus ) ;
420+ }
380421 } ) ;
381422
382423 it ( "should create an event with video call data" , ( ) => {
@@ -401,7 +442,10 @@ describe("CalendarEventBuilder", () => {
401442 . withVideoCallData ( videoCallData )
402443 . build ( ) ;
403444
404- expect ( event . videoCallData ) . toEqual ( videoCallData ) ;
445+ expect ( event ) . not . toBeNull ( ) ;
446+ if ( event ) {
447+ expect ( event . videoCallData ) . toEqual ( videoCallData ) ;
448+ }
405449 } ) ;
406450
407451 it ( "should create an event with team information" , ( ) => {
@@ -435,7 +479,10 @@ describe("CalendarEventBuilder", () => {
435479 . withTeam ( team )
436480 . build ( ) ;
437481
438- expect ( event . team ) . toEqual ( team ) ;
482+ expect ( event ) . not . toBeNull ( ) ;
483+ if ( event ) {
484+ expect ( event . team ) . toEqual ( team ) ;
485+ }
439486 } ) ;
440487
441488 it ( "should create an event with recurring event information" , ( ) => {
@@ -459,7 +506,10 @@ describe("CalendarEventBuilder", () => {
459506 . withRecurring ( recurringEvent )
460507 . build ( ) ;
461508
462- expect ( event . recurringEvent ) . toEqual ( recurringEvent ) ;
509+ expect ( event ) . not . toBeNull ( ) ;
510+ if ( event ) {
511+ expect ( event . recurringEvent ) . toEqual ( recurringEvent ) ;
512+ }
463513 } ) ;
464514
465515 it ( "should create an event with attendee seat ID" , ( ) => {
@@ -477,7 +527,10 @@ describe("CalendarEventBuilder", () => {
477527 . withAttendeeSeatId ( "seat-123" )
478528 . build ( ) ;
479529
480- expect ( event . attendeeSeatId ) . toBe ( "seat-123" ) ;
530+ expect ( event ) . not . toBeNull ( ) ;
531+ if ( event ) {
532+ expect ( event . attendeeSeatId ) . toBe ( "seat-123" ) ;
533+ }
481534 } ) ;
482535
483536 it ( "should create an event with UID" , ( ) => {
@@ -495,7 +548,10 @@ describe("CalendarEventBuilder", () => {
495548 . withUid ( "booking-uid-123" )
496549 . build ( ) ;
497550
498- expect ( event . uid ) . toBe ( "booking-uid-123" ) ;
551+ expect ( event ) . not . toBeNull ( ) ;
552+ if ( event ) {
553+ expect ( event . uid ) . toBe ( "booking-uid-123" ) ;
554+ }
499555 } ) ;
500556
501557 it ( "should create an event with one-time password" , ( ) => {
@@ -513,7 +569,10 @@ describe("CalendarEventBuilder", () => {
513569 . withOneTimePassword ( "otp123" )
514570 . build ( ) ;
515571
516- expect ( event . oneTimePassword ) . toBe ( "otp123" ) ;
572+ expect ( event ) . not . toBeNull ( ) ;
573+ if ( event ) {
574+ expect ( event . oneTimePassword ) . toBe ( "otp123" ) ;
575+ }
517576 } ) ;
518577
519578 it ( "should create an event with recurring event ID" , ( ) => {
@@ -531,9 +590,12 @@ describe("CalendarEventBuilder", () => {
531590 . withRecurringEventId ( "recurring-123" )
532591 . build ( ) ;
533592
534- expect ( event . existingRecurringEvent ) . toEqual ( {
535- recurringEventId : "recurring-123" ,
536- } ) ;
593+ expect ( event ) . not . toBeNull ( ) ;
594+ if ( event ) {
595+ expect ( event . existingRecurringEvent ) . toEqual ( {
596+ recurringEventId : "recurring-123" ,
597+ } ) ;
598+ }
537599 } ) ;
538600
539601 it ( "should create a complete calendar event with all properties" , ( ) => {
@@ -597,6 +659,8 @@ describe("CalendarEventBuilder", () => {
597659 userId : 1 ,
598660 eventTypeId : 123 ,
599661 credentialId : 1 ,
662+ createdAt : null ,
663+ updatedAt : null ,
600664 delegationCredentialId : null ,
601665 domainWideDelegationCredentialId : null ,
602666 } ,
@@ -644,26 +708,29 @@ describe("CalendarEventBuilder", () => {
644708 . build ( ) ;
645709
646710 // Test that all properties are set correctly
647- expect ( event . title ) . toBe ( "Complete Test Event" ) ;
648- expect ( event . type ) . toBe ( "complete-test" ) ;
649- expect ( event . organizer . name ) . toBe ( "John Doe" ) ;
650- expect ( event . attendees ) . toHaveLength ( 1 ) ;
651- expect ( event . location ) . toBe ( "Conference Room A" ) ;
652- expect ( event . iCalUID ) . toBe ( "ical-123" ) ;
653- expect ( event . requiresConfirmation ) . toBe ( true ) ;
654- expect ( event . platformClientId ) . toBe ( "client-123" ) ;
655- expect ( event . appsStatus ) . toHaveLength ( 1 ) ;
656- expect ( event . videoCallData ?. url ) . toBe ( "https://meet.example.com/123" ) ;
657- expect ( event . team ?. name ) . toBe ( "Engineering Team" ) ;
658- expect ( event . recurringEvent ?. count ) . toBe ( 5 ) ;
659- expect ( event . attendeeSeatId ) . toBe ( "seat-123" ) ;
660- expect ( event . uid ) . toBe ( "booking-uid-123" ) ;
661- expect ( event . oneTimePassword ) . toBe ( "otp123" ) ;
711+ expect ( event ) . not . toBeNull ( ) ;
712+ if ( event ) {
713+ expect ( event . title ) . toBe ( "Complete Test Event" ) ;
714+ expect ( event . type ) . toBe ( "complete-test" ) ;
715+ expect ( event . organizer . name ) . toBe ( "John Doe" ) ;
716+ expect ( event . attendees ) . toHaveLength ( 1 ) ;
717+ expect ( event . location ) . toBe ( "Conference Room A" ) ;
718+ expect ( event . iCalUID ) . toBe ( "ical-123" ) ;
719+ expect ( event . requiresConfirmation ) . toBe ( true ) ;
720+ expect ( event . platformClientId ) . toBe ( "client-123" ) ;
721+ expect ( event . appsStatus ) . toHaveLength ( 1 ) ;
722+ expect ( event . videoCallData ?. url ) . toBe ( "https://meet.example.com/123" ) ;
723+ expect ( event . team ?. name ) . toBe ( "Engineering Team" ) ;
724+ expect ( event . recurringEvent ?. count ) . toBe ( 5 ) ;
725+ expect ( event . attendeeSeatId ) . toBe ( "seat-123" ) ;
726+ expect ( event . uid ) . toBe ( "booking-uid-123" ) ;
727+ expect ( event . oneTimePassword ) . toBe ( "otp123" ) ;
728+ }
662729 } ) ;
663730
664- it ( "should throw an error when building without required fields" , ( ) => {
731+ it ( "should return null when building without required fields" , ( ) => {
665732 const builder = new CalendarEventBuilder ( ) ;
666- expect ( ( ) => builder . build ( ) ) . toThrow ( "Missing required fields for calendar event" ) ;
733+ expect ( builder . build ( ) ) . toBeNull ( ) ;
667734 } ) ;
668735
669736 it ( "should create an event from an existing event" , ( ) => {
@@ -684,8 +751,11 @@ describe("CalendarEventBuilder", () => {
684751 } )
685752 . build ( ) ;
686753
687- expect ( event . title ) . toBe ( "Updated Event" ) ;
688- expect ( event . type ) . toBe ( "existing-type" ) ;
754+ expect ( event ) . not . toBeNull ( ) ;
755+ if ( event ) {
756+ expect ( event . title ) . toBe ( "Updated Event" ) ;
757+ expect ( event . type ) . toBe ( "existing-type" ) ;
758+ }
689759 } ) ;
690760
691761 it ( "should propagate disableCancelling and disableRescheduling" , ( ) => {
@@ -706,7 +776,10 @@ describe("CalendarEventBuilder", () => {
706776 } )
707777 . build ( ) ;
708778
709- expect ( event . disableCancelling ) . toBe ( true ) ;
710- expect ( event . disableRescheduling ) . toBe ( true ) ;
779+ expect ( event ) . not . toBeNull ( ) ;
780+ if ( event ) {
781+ expect ( event . disableCancelling ) . toBe ( true ) ;
782+ expect ( event . disableRescheduling ) . toBe ( true ) ;
783+ }
711784 } ) ;
712785} ) ;
0 commit comments