diff --git a/backend/src/mailer/sendEMail.test.ts b/backend/src/mailer/sendEMail.test.ts index 5746f1ead..8e3b0c4a2 100644 --- a/backend/src/mailer/sendEMail.test.ts +++ b/backend/src/mailer/sendEMail.test.ts @@ -29,6 +29,7 @@ describe('sendEMail', () => { let result: boolean describe('config email is false', () => { beforeEach(async () => { + jest.clearAllMocks() result = await sendEMail({ to: 'receiver@mail.org', cc: 'support@gradido.net', @@ -48,6 +49,7 @@ describe('sendEMail', () => { describe('config email is true', () => { beforeEach(async () => { + jest.clearAllMocks() CONFIG.EMAIL = true result = await sendEMail({ to: 'receiver@mail.org', @@ -84,4 +86,28 @@ describe('sendEMail', () => { expect(result).toBeTruthy() }) }) + + describe('with email EMAIL_TEST_MODUS true', () => { + beforeEach(async () => { + jest.clearAllMocks() + CONFIG.EMAIL = true + CONFIG.EMAIL_TEST_MODUS = true + result = await sendEMail({ + to: 'receiver@mail.org', + cc: 'support@gradido.net', + subject: 'Subject', + text: 'Text text text', + }) + }) + + it('calls sendMail of transporter with faked to', () => { + expect((createTransport as jest.Mock).mock.results[0].value.sendMail).toBeCalledWith({ + from: `Gradido (nicht antworten) <${CONFIG.EMAIL_SENDER}>`, + to: CONFIG.EMAIL_TEST_RECEIVER, + cc: 'support@gradido.net', + subject: 'Subject', + text: 'Text text text', + }) + }) + }) })