2021-08-12 15:04:37 +02:00
|
|
|
import { EmailService } from './email-service';
|
2021-04-09 11:16:06 +02:00
|
|
|
import noLoggerProvider from '../../test/fixtures/no-logger';
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('Can send reset email', async () => {
|
2021-04-09 11:16:06 +02:00
|
|
|
const emailService = new EmailService(
|
|
|
|
{
|
2021-04-16 15:29:23 +02:00
|
|
|
host: 'test',
|
2021-04-09 11:16:06 +02:00
|
|
|
port: 587,
|
|
|
|
secure: false,
|
2021-04-22 10:07:10 +02:00
|
|
|
smtpuser: '',
|
|
|
|
smtppass: '',
|
2021-04-09 11:16:06 +02:00
|
|
|
sender: 'noreply@getunleash.ai',
|
|
|
|
},
|
|
|
|
noLoggerProvider,
|
|
|
|
);
|
2021-04-16 15:29:23 +02:00
|
|
|
const resetLinkUrl =
|
|
|
|
'https://unleash-hosted.com/reset-password?token=$2b$10$M06Ysso6KL4ueH/xR6rdSuY5GSymdIwmIkEUJMRkB.Qn26r5Gi5vW';
|
|
|
|
|
2021-04-09 11:16:06 +02:00
|
|
|
const content = await emailService.sendResetMail(
|
|
|
|
'Some username',
|
2021-04-16 15:29:23 +02:00
|
|
|
'test@resetLinkUrl.com',
|
|
|
|
resetLinkUrl,
|
2021-04-09 11:16:06 +02:00
|
|
|
);
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(content.from).toBe('noreply@getunleash.ai');
|
|
|
|
expect(content.subject).toBe('Unleash - Reset your password');
|
|
|
|
expect(content.html.includes(resetLinkUrl)).toBe(true);
|
|
|
|
expect(content.text.includes(resetLinkUrl)).toBe(true);
|
2021-04-09 11:16:06 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('Can send welcome mail', async () => {
|
2021-04-09 11:16:06 +02:00
|
|
|
const emailService = new EmailService(
|
|
|
|
{
|
2021-04-16 15:29:23 +02:00
|
|
|
host: 'test',
|
2021-04-09 11:16:06 +02:00
|
|
|
port: 9999,
|
|
|
|
secure: false,
|
|
|
|
sender: 'noreply@getunleash.ai',
|
2021-04-22 10:07:10 +02:00
|
|
|
smtpuser: '',
|
|
|
|
smtppass: '',
|
2021-04-09 11:16:06 +02:00
|
|
|
},
|
|
|
|
noLoggerProvider,
|
|
|
|
);
|
|
|
|
const content = await emailService.sendGettingStartedMail(
|
|
|
|
'Some username',
|
|
|
|
'test@test.com',
|
|
|
|
'abc123456',
|
|
|
|
);
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(content.from).toBe('noreply@getunleash.ai');
|
|
|
|
expect(content.subject).toBe('Welcome to Unleash');
|
2021-04-09 11:16:06 +02:00
|
|
|
});
|