Skip to content

Commit 9cabe15

Browse files
authored
Fix nylas-nodejs issue 678 with tests (#679)
1 parent a2000bf commit 9cabe15

File tree

3 files changed

+140
-1
lines changed

3 files changed

+140
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Fixed
11+
- Make `conferencing` property optional in `Event` model to handle events without conferencing details ([#678](https://github.com/nylas/nylas-nodejs/issues/678))
12+
813
## [7.13.2] - 2025-10-01
914

1015
### Fixed

src/models/events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export interface Event {
6464
* - {@link Autocreate}
6565
* - {@link Details}
6666
*/
67-
conferencing: Conferencing;
67+
conferencing?: Conferencing;
6868
/**
6969
* Visibility of the event, if the event is private or public.
7070
*/

tests/resources/events.spec.ts

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,4 +486,138 @@ describe('Events', () => {
486486
});
487487
});
488488
});
489+
490+
describe('Event model with optional conferencing', () => {
491+
it('should handle events without conferencing property', async () => {
492+
const eventWithoutConferencing = {
493+
requestId: 'request123',
494+
data: {
495+
id: 'event123',
496+
grantId: 'grant123',
497+
object: 'event' as const,
498+
calendarId: 'calendar123',
499+
busy: false,
500+
readOnly: false,
501+
participants: [],
502+
when: {
503+
time: 1617235200,
504+
timezone: 'America/New_York',
505+
object: 'time' as const,
506+
},
507+
visibility: 'default' as const,
508+
title: 'Event without conferencing',
509+
},
510+
};
511+
512+
apiClient.request.mockResolvedValue(eventWithoutConferencing);
513+
514+
const result = await events.find({
515+
identifier: 'id123',
516+
eventId: 'event123',
517+
queryParams: {
518+
calendarId: 'calendar123',
519+
},
520+
});
521+
522+
expect(result.data.conferencing).toBeUndefined();
523+
expect(result.data.title).toBe('Event without conferencing');
524+
});
525+
526+
it('should handle events with conferencing property', async () => {
527+
const eventWithConferencing = {
528+
requestId: 'request123',
529+
data: {
530+
id: 'event123',
531+
grantId: 'grant123',
532+
object: 'event' as const,
533+
calendarId: 'calendar123',
534+
busy: false,
535+
readOnly: false,
536+
participants: [],
537+
when: {
538+
time: 1617235200,
539+
timezone: 'America/New_York',
540+
object: 'time' as const,
541+
},
542+
conferencing: {
543+
provider: 'Zoom Meeting' as const,
544+
details: {
545+
url: 'https://zoom.us/j/123456789',
546+
meetingCode: '123456789',
547+
},
548+
},
549+
visibility: 'default' as const,
550+
title: 'Event with conferencing',
551+
},
552+
};
553+
554+
apiClient.request.mockResolvedValue(eventWithConferencing);
555+
556+
const result = await events.find({
557+
identifier: 'id123',
558+
eventId: 'event456',
559+
queryParams: {
560+
calendarId: 'calendar123',
561+
},
562+
});
563+
564+
expect(result.data.conferencing).toBeDefined();
565+
expect(result.data.conferencing?.provider).toBe('Zoom Meeting');
566+
expect(result.data.title).toBe('Event with conferencing');
567+
});
568+
569+
it('should create events without conferencing', async () => {
570+
const eventResponse = {
571+
requestId: 'request123',
572+
data: {
573+
id: 'event123',
574+
grantId: 'grant123',
575+
object: 'event' as const,
576+
calendarId: 'calendar123',
577+
busy: false,
578+
readOnly: false,
579+
participants: [],
580+
when: {
581+
time: 1617235200,
582+
timezone: 'America/New_York',
583+
object: 'time' as const,
584+
},
585+
visibility: 'default' as const,
586+
title: 'Simple event',
587+
},
588+
};
589+
590+
apiClient.request.mockResolvedValue(eventResponse);
591+
592+
const result = await events.create({
593+
identifier: 'id123',
594+
requestBody: {
595+
when: {
596+
time: 1617235200,
597+
timezone: 'America/New_York',
598+
},
599+
title: 'Simple event',
600+
},
601+
queryParams: {
602+
calendarId: 'calendar123',
603+
},
604+
});
605+
606+
expect(apiClient.request).toHaveBeenCalledWith({
607+
method: 'POST',
608+
path: '/v3/grants/id123/events',
609+
body: {
610+
when: {
611+
time: 1617235200,
612+
timezone: 'America/New_York',
613+
},
614+
title: 'Simple event',
615+
},
616+
queryParams: {
617+
calendarId: 'calendar123',
618+
},
619+
});
620+
expect(result.data.conferencing).toBeUndefined();
621+
});
622+
});
489623
});

0 commit comments

Comments
 (0)