Skip to content

Commit

Permalink
feat(productivity-report): additional email headers test (#8540)
Browse files Browse the repository at this point in the history
Test ability to add custom header to non-transactional email.
  • Loading branch information
Tymek authored Dec 9, 2024
1 parent d40b079 commit e8179d4
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/lib/services/email-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,45 @@ test('Can send productivity report email', async () => {
expect(content.text.includes(`localhost/insights`)).toBe(true);
expect(content.text.includes(`localhost/profile`)).toBe(true);
});

test('Should add optional headers to productivity email', async () => {
const emailService = new EmailService({
server: {
unleashUrl: 'http://localhost',
},
email: {
host: 'test',
port: 587,
secure: false,
smtpuser: '',
smtppass: '',
sender: '[email protected]',
optionalHeaders: {
'x-header-name': 'value',
},
},
getLogger: noLoggerProvider,
} as unknown as IUnleashConfig);

const passwordResetMail = await emailService.sendResetMail(
'name',
'[email protected]',
'http://exempla.com',
);

const productivityMail = await emailService.sendProductivityReportEmail(
'[email protected]',
'customerId',
{
flagsCreated: 1,
productionUpdates: 2,
health: 99,
},
);

expect(passwordResetMail.headers).toBeFalsy();

expect(productivityMail.headers).toStrictEqual({
'x-header-name': 'value',
});
});

0 comments on commit e8179d4

Please sign in to comment.