diff --git a/backend/src/util/sendEMail.test.ts b/backend/src/util/sendEMail.test.ts index 60b338974..76f7ad016 100644 --- a/backend/src/util/sendEMail.test.ts +++ b/backend/src/util/sendEMail.test.ts @@ -1,4 +1,4 @@ -import { sendEMail } from './sendEMail' +import sendEmail from './sendEMail' import { createTransport } from 'nodemailer' import CONFIG from '../config' @@ -32,7 +32,7 @@ describe('sendEMail', () => { // eslint-disable-next-line no-console console.log = consoleLogMock beforeEach(async () => { - result = await sendEMail({ + result = await sendEmail.sendEMail({ from: 'sender@mail.org', to: 'receiver@mail.org', subject: 'Subject', @@ -57,7 +57,7 @@ describe('sendEMail', () => { describe('config email is true', () => { beforeEach(async () => { CONFIG.EMAIL = true - result = await sendEMail({ + result = await sendEmail.sendEMail({ from: 'sender@mail.org', to: 'receiver@mail.org', subject: 'Subject', @@ -83,3 +83,29 @@ describe('sendEMail', () => { }) }) }) + +describe('sendAccountActivationEmail', () => { + const spy = jest.spyOn(sendEmail, 'sendEMail') + beforeEach(async () => { + jest.clearAllMocks() + await sendEmail.sendAccountActivationEmail( + 'activationLink', + 'Petet', + 'Lustig', + 'peter@lustig.de', + ) + }) + + it.skip('calls sendEMail', () => { + expect(spy).toBeCalledWith( + expect.objectContaining({ + from: `Gradido (nicht antworten) <${CONFIG.EMAIL_SENDER}>`, + to: `Peter Lustig `, + subject: 'Gradido: E-Mail Überprüfung', + text: + expect.stringContaining('Hallo Peter Lustig') && + expect.stringContaining('activationLink'), + }), + ) + }) +}) diff --git a/backend/src/util/sendEMail.ts b/backend/src/util/sendEMail.ts index 0221c001c..5ef2117b7 100644 --- a/backend/src/util/sendEMail.ts +++ b/backend/src/util/sendEMail.ts @@ -2,7 +2,7 @@ import { createTransport } from 'nodemailer' import CONFIG from '../config' -const sendEMail = async (emailDef: { +export const sendEMail = async (emailDef: { from: string to: string subject: string @@ -30,7 +30,7 @@ const sendEMail = async (emailDef: { return true } -const sendAccountActivationEmail = ( +export const sendAccountActivationEmail = ( activationLink: string, firstName: string, lastName: string, @@ -53,4 +53,4 @@ const sendAccountActivationEmail = ( }) } -export { sendAccountActivationEmail, sendEMail } +export default { sendAccountActivationEmail, sendEMail }