Skip to content

Commit

Permalink
extended a unit test on updateAnnouncement to confirm that the correc…
Browse files Browse the repository at this point in the history
…t 'updated_date' is saved to the db
  • Loading branch information
banders committed Dec 11, 2024
1 parent fa02161 commit c8ef9aa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/src/v1/services/announcements-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ describe('AnnouncementsService', () => {
linkDisplayName: faker.lorem.words(3),
linkUrl: faker.internet.url(),
};
const now = new Date();
await announcementService.updateAnnouncement(
'announcement-id',
announcementInput,
Expand Down Expand Up @@ -738,6 +739,16 @@ describe('AnnouncementsService', () => {
}),
}),
);

//Ensure the update date saved to the database is approximately now
//(within 5 seconds of now)
const updateObj = mockUpdate.mock.calls[0][0];
const updatedDate = updateObj.data.updated_date;
const expectedUpdateDate = now;
const updateDateDiffMs =
updatedDate.getTime() - expectedUpdateDate.getTime();
expect(updateDateDiffMs).toBeGreaterThanOrEqual(0);
expect(updateDateDiffMs).toBeLessThan(5000);
});
});
describe('with existing attachment resource', () => {
Expand Down

0 comments on commit c8ef9aa

Please sign in to comment.