-
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.
Merge pull request #12 from yamitzky/feat/day-before-reminder
feat: add support for day-before reminders
- Loading branch information
Showing
10 changed files
with
187 additions
and
103 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
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 |
---|---|---|
|
@@ -4,17 +4,17 @@ import { parseConfig } from './config' | |
|
||
describe('Config', () => { | ||
it('should parse valid configuration', () => { | ||
const mockEnv = { | ||
const mockEnv: NodeJS.ProcessEnv = { | ||
NODE_ENV: 'test', | ||
GOOGLE_AUTH_SUBJECT: '[email protected]', | ||
CALENDAR_IDS: 'calendar1,calendar2', | ||
REMINDER_SETTINGS: JSON.stringify([ | ||
{ minutesBefore: 10, notificationType: 'email' }, | ||
{ minutesBefore: 30, notificationType: 'sms', target: '+1234567890' }, | ||
{ hour: 9, minute: 0, notificationType: 'sms', target: '+1234567890' }, | ||
]), | ||
REMINDER_TEMPLATE: 'Your event {eventName} starts in {minutesBefore} minutes', | ||
WEBHOOK_URL: 'https://example.com/webhook', | ||
CALENDAR_PROVIDER: 'google', | ||
REMINDER_MINUTES_BEFORE_OPTIONS: '1,2,3,4,5', | ||
REMINDER_SETTINGS_FIRESTORE_DATABASE_ID: 'test', | ||
REMINDER_SETTINGS_PROVIDER: 'firestore', | ||
AUTH_PROVIDER: 'google-iap', | ||
|
@@ -25,61 +25,68 @@ describe('Config', () => { | |
expect(parsedConfig).toEqual({ | ||
GOOGLE_AUTH_SUBJECT: '[email protected]', | ||
CALENDAR_IDS: ['calendar1', 'calendar2'], | ||
TIMEZONE: 'UTC', | ||
REMINDER_SETTINGS: [ | ||
{ minutesBefore: 10, notificationType: 'email' }, | ||
{ minutesBefore: 30, notificationType: 'sms', target: '+1234567890' }, | ||
{ hour: 9, minute: 0, notificationType: 'sms', target: '+1234567890' }, | ||
], | ||
REMINDER_TEMPLATE: 'Your event {eventName} starts in {minutesBefore} minutes', | ||
WEBHOOK_URL: 'https://example.com/webhook', | ||
REMINDER_SETTINGS_PROVIDER: 'firestore', | ||
REMINDER_SETTINGS_FIRESTORE_DATABASE_ID: 'test', | ||
REMINDER_MINUTES_BEFORE_OPTIONS: [1, 2, 3, 4, 5], | ||
CALENDAR_PROVIDER: 'google', | ||
AUTH_PROVIDER: 'google-iap', | ||
}) | ||
}) | ||
|
||
it('should handle missing optional values', () => { | ||
const mockEnv = { | ||
const mockEnv: NodeJS.ProcessEnv = { | ||
CALENDAR_IDS: 'calendar1', | ||
NODE_ENV: 'test', | ||
} | ||
|
||
const parsedConfig = parseConfig(mockEnv) | ||
|
||
expect(parsedConfig).toEqual({ | ||
GOOGLE_AUTH_SUBJECT: undefined, | ||
CALENDAR_IDS: ['calendar1'], | ||
TIMEZONE: 'UTC', | ||
REMINDER_SETTINGS: [], | ||
REMINDER_TEMPLATE: undefined, | ||
WEBHOOK_URL: undefined, | ||
REMINDER_SETTINGS_PROVIDER: 'global', | ||
REMINDER_SETTINGS_FIRESTORE_DATABASE_ID: undefined, | ||
REMINDER_MINUTES_BEFORE_OPTIONS: [5, 10, 15, 30, 60, 120, 180, 360, 720, 1440], | ||
AUTH_PROVIDER: undefined, | ||
CALENDAR_PROVIDER: 'google', | ||
}) | ||
}) | ||
|
||
it('should throw an error for invalid WEBHOOK_URL', () => { | ||
const mockEnv = { | ||
const mockEnv: NodeJS.ProcessEnv = { | ||
WEBHOOK_URL: 'invalid-url', | ||
NODE_ENV: 'test', | ||
} | ||
|
||
expect(() => parseConfig(mockEnv)).toThrow(v.ValiError) | ||
}) | ||
|
||
it('should throw an error for invalid REMINDER_SETTINGS', () => { | ||
const mockEnv = { | ||
REMINDER_SETTINGS: JSON.stringify([{ minutesBefore: 'invalid', notificationType: 'email' }]), | ||
} | ||
NODE_ENV: 'test', | ||
REMINDER_SETTINGS: JSON.stringify([ | ||
{ minutesBefore: 'invalid', notificationType: 'email' }, | ||
{ hour: 25, minute: 0, notificationType: 'email' }, | ||
]), | ||
} as NodeJS.ProcessEnv | ||
|
||
expect(() => parseConfig(mockEnv)).toThrow(v.ValiError) | ||
}) | ||
|
||
it('should throw an error for invalid REMINDER_SETTINGS JSON', () => { | ||
const mockEnv = { | ||
REMINDER_SETTINGS: 'invalid-json', | ||
} | ||
NODE_ENV: 'test', | ||
} as NodeJS.ProcessEnv | ||
|
||
expect(() => parseConfig(mockEnv)).toThrow('Invalid REMINDER_SETTINGS JSON') | ||
}) | ||
|
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
Oops, something went wrong.