From 5381e7380ae6060f6644b0d04c64f51ee82c27ec Mon Sep 17 00:00:00 2001 From: Walter Moar Date: Thu, 7 Mar 2024 08:07:28 -0800 Subject: [PATCH] fix: FORMS-1037 handle missing submission schedule (#1304) --- app/src/forms/email/reminderService.js | 2 ++ app/tests/unit/forms/email/reminderService.spec.js | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/src/forms/email/reminderService.js b/app/src/forms/email/reminderService.js index ab6d70d68..eabe6950d 100644 --- a/app/src/forms/email/reminderService.js +++ b/app/src/forms/email/reminderService.js @@ -124,6 +124,8 @@ const service = { }), ]; } + + return []; }, _getGraceDate: (schedule) => { let substartDate = moment(schedule.openSubmissionDateTime); diff --git a/app/tests/unit/forms/email/reminderService.spec.js b/app/tests/unit/forms/email/reminderService.spec.js index a43356239..61696ac15 100644 --- a/app/tests/unit/forms/email/reminderService.spec.js +++ b/app/tests/unit/forms/email/reminderService.spec.js @@ -27,6 +27,16 @@ const schedule = { closeSubmissionDateTime: null, }; +describe('_init', () => { + it('should handle reminder enabled with empty schedule', async () => { + reminderService._getForms = jest.fn().mockReturnValue([{ schedule: {} }]); + + const result = await reminderService._init(); + + expect(result.errors).not.toBe([]); + }); +}); + describe('getDifference', () => { it('should return the difference between 2 arrays of object', () => { let obj1 = [