-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
57 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ describe('Config', () => { | |
expect(parsedConfig).toEqual({ | ||
GOOGLE_AUTH_SUBJECT: '[email protected]', | ||
CALENDAR_IDS: ['calendar1', 'calendar2'], | ||
TIMEZONE: 'UTC', | ||
REMINDER_SETTINGS: [ | ||
{ minutesBefore: 10, notificationType: 'email' }, | ||
{ hour: 9, minute: 0, notificationType: 'sms', target: '+1234567890' }, | ||
|
@@ -49,6 +50,7 @@ describe('Config', () => { | |
expect(parsedConfig).toEqual({ | ||
GOOGLE_AUTH_SUBJECT: undefined, | ||
CALENDAR_IDS: ['calendar1'], | ||
TIMEZONE: 'UTC', | ||
REMINDER_SETTINGS: [], | ||
REMINDER_TEMPLATE: undefined, | ||
WEBHOOK_URL: undefined, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import { processReminders } from './process_reminders' | |
vi.mock('@synk-cal/core', () => ({ | ||
config: { | ||
REMINDER_TEMPLATE: 'Custom reminder: <%= it.title %> <%= it.minutesBefore ? `in ${it.minutesBefore} minutes` : `tomorrow at ${String(it.hour).padStart(2, "0")}:${String(it.minute).padStart(2, "0")}` %>.', | ||
TIMEZONE: 'UTC', | ||
}, | ||
})) | ||
|
||
|
@@ -116,7 +117,7 @@ describe('processReminders', () => { | |
}) | ||
|
||
it('should send notifications for day before at specific hour', async () => { | ||
const baseTime = parseISO('2023-06-01T10:00:00Z') // 19:00 JST | ||
const baseTime = parseISO('2023-06-01T19:00:00Z') // UTC 19:00 | ||
const eventStart = parseISO('2023-06-02T10:00:00Z') | ||
|
||
vi.mocked(mockCalendarRepository.getEvents).mockResolvedValue([ | ||
|
@@ -153,14 +154,14 @@ describe('processReminders', () => { | |
}) | ||
|
||
it('should handle multiple attendees for the same event', async () => { | ||
const baseTime = parseISO('2023-06-01T10:00:00Z') | ||
const eventStart = parseISO('2023-06-01T10:10:00Z') | ||
const baseTime = parseISO('2023-06-01T19:00:00Z') | ||
const eventStart = parseISO('2023-06-02T10:10:00Z') | ||
|
||
vi.mocked(mockCalendarRepository.getEvents).mockResolvedValue([ | ||
{ | ||
id: '1', | ||
start: eventStart.toISOString(), | ||
end: parseISO('2023-06-01T11:10:00Z').toISOString(), | ||
end: parseISO('2023-06-02T11:10:00Z').toISOString(), | ||
title: 'Event 1', | ||
people: [ | ||
{ email: '[email protected]', organizer: false }, | ||
|
@@ -200,17 +201,25 @@ describe('processReminders', () => { | |
}) | ||
|
||
it('should handle multiple reminder settings for the same user', async () => { | ||
const baseTime = parseISO('2023-06-01T10:00:00Z') | ||
const eventStart = parseISO('2023-06-01T10:10:00Z') | ||
const baseTime = parseISO('2023-06-01T19:00:00Z') | ||
const event1Start = parseISO('2023-06-01T19:10:00Z') // For minutesBefore | ||
const event2Start = parseISO('2023-06-02T10:10:00Z') // For hour/minute | ||
|
||
vi.mocked(mockCalendarRepository.getEvents).mockResolvedValue([ | ||
{ | ||
id: '1', | ||
start: eventStart.toISOString(), | ||
end: parseISO('2023-06-01T11:10:00Z').toISOString(), | ||
start: event1Start.toISOString(), | ||
end: parseISO('2023-06-01T20:10:00Z').toISOString(), | ||
title: 'Event 1', | ||
people: [{ email: '[email protected]', organizer: false }], | ||
}, | ||
{ | ||
id: '2', | ||
start: event2Start.toISOString(), | ||
end: parseISO('2023-06-02T11:10:00Z').toISOString(), | ||
title: 'Event 2', | ||
people: [{ email: '[email protected]', organizer: false }], | ||
}, | ||
]) | ||
|
||
const reminderSettingsMap: Record<string, ReminderSetting[]> = { | ||
|
@@ -241,7 +250,7 @@ describe('processReminders', () => { | |
|
||
expect(mockWebhookNotificationRepository.notify).toHaveBeenCalledWith( | ||
'[email protected]', | ||
'Custom reminder: Event 1 tomorrow at 19:00.', | ||
'Custom reminder: Event 2 tomorrow at 19:00.', | ||
) | ||
}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.