Skip to content

Commit

Permalink
test: refactor email test for Doorway conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredcwhite committed Jan 24, 2025
1 parent ab9a80b commit 513ea6e
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions api/test/unit/services/email.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,23 +682,36 @@ describe('Testing email service', () => {

describe('lottery published for applicant', () => {
it('should generate html body', async () => {
const emailArr = ['testOne@xample.com', '[email protected]'];
const emailArr = ['testOne@example.com', '[email protected]'];
const service = await module.resolve(EmailService);
await service.lotteryPublishedApplicant(
{ name: 'listing name', id: 'listingId', juris: 'jurisdictionId' },
{ en: emailArr },
);

expect(sendMock).toHaveBeenCalled();
const emailMock = sendMock.mock.calls[0][0];
expect(emailMock.to).toEqual(emailArr);
expect(emailMock.subject).toEqual(
'New Housing Lottery Results Available',
);
expect(emailMock.html).toMatch(
/href="https:\/\/example\.com\/en\/sign-in"/,
);
expect(emailMock.html).toMatch(/please visit https:\/\/example\.com/);
expect(mockSeSClient).toHaveReceivedCommandWith(SendBulkEmailCommand, {
FromEmailAddress: 'Doorway <[email protected]>',
BulkEmailEntries: expect.arrayContaining([
{ Destination: { ToAddresses: ['[email protected]'] } },
{ Destination: { ToAddresses: ['[email protected]'] } },
]),
DefaultContent: {
Template: {
TemplateContent: {
Subject: `New Housing Lottery Results Available`,
Html: expect.anything(),
},
TemplateData: expect.anything(),
},
},
});
const html =
mockSeSClient.call(0).args[0].input['DefaultContent']['Template'][
'TemplateContent'
]['Html'];

expect(html).toMatch(/href="https:\/\/example\.com\/en\/sign-in"/);
expect(html).toMatch(/please visit https:\/\/example\.com/);
});
});
});

0 comments on commit 513ea6e

Please sign in to comment.