Skip to content

Commit

Permalink
test: fix cronjobs test
Browse files Browse the repository at this point in the history
  • Loading branch information
yxuo committed Feb 21, 2024
1 parent 5b20e04 commit 4f70610
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/test/test.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export class TestService {
const testMails =
(await this.mailHistoryService.find({
email: In([
'queued.user@example.com',
'sent.user@example.com',
'used.user@example.com',
'registered.user@example.com',
Expand Down
12 changes: 4 additions & 8 deletions test/cron-jobs/cron-jobs.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,22 @@ describe('CronJobs (e2e)', () => {
await request(app)
.get('/api/v1/test/cron-jobs/bulk-resend-invites')
.expect(200);
const resendInvitesLocalDate = new Date();
resendInvitesLocalDate.setMinutes(
resendInvitesLocalDate.getMinutes() + global.__localTzOffset,
);
const resendInvitesDate = new Date();

const mails = await request(MAILDEV_URL)
.get('/email')
.then(({ body }) =>
(body as IMaildevEmail[])
.filter(
(mail) =>
differenceInSeconds(
resendInvitesLocalDate,
new Date(mail.date),
) <= 10,
differenceInSeconds(resendInvitesDate, new Date(mail.date)) <=
10,
)
.map((mail) => ({
purpose: mail.text.split(' ')?.[0],
URL: mail.text.split(' ')?.[1],
to: mail.headers.to,
date: mail.date,
})),
);

Expand Down

0 comments on commit 4f70610

Please sign in to comment.