Test that 'sendEmailTranslated' on 'CONFIG.EMAIL_TEST_MODUS = true' replaces the receiver with by the fake test mail accaount

This commit is contained in:
Wolfgang Huß 2022-11-28 09:38:19 +01:00
parent 2b65c6b261
commit 0cccdb56de

View File

@ -107,4 +107,41 @@ describe('sendEmailTranslated', () => {
expect(i18n.__).toBeCalled()
})
})
describe('with email EMAIL_TEST_MODUS true', () => {
beforeEach(async () => {
jest.clearAllMocks()
CONFIG.EMAIL = true
CONFIG.EMAIL_TEST_MODUS = true
result = await sendEmailTranslated({
receiver: {
to: 'receiver@mail.org',
cc: 'support@gradido.net',
},
template: 'accountMultiRegistration',
locals: {
locale: 'en',
},
})
})
it('call of "sendEmailTranslated" with faked "to"', () => {
expect(result).toMatchObject({
envelope: {
from: CONFIG.EMAIL_SENDER,
to: [CONFIG.EMAIL_TEST_RECEIVER, 'support@gradido.net'],
},
message: expect.any(String),
originalMessage: expect.objectContaining({
to: CONFIG.EMAIL_TEST_RECEIVER,
cc: 'support@gradido.net',
from: `Gradido (nicht antworten) <${CONFIG.EMAIL_SENDER}>`,
attachments: [],
subject: 'Gradido: Try To Register Again With Your Email',
html: expect.stringContaining('Gradido: Try To Register Again With Your Email'),
text: expect.stringContaining('GRADIDO: TRY TO REGISTER AGAIN WITH YOUR EMAIL'),
}),
})
})
})
})