From 9894b02f5110263c70031f95a555fa6fc78d8d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Mon, 28 Nov 2022 10:54:31 +0100 Subject: [PATCH] Test 'sendTransactionReceivedEmail' --- backend/src/emails/sendEmailVariants.test.ts | 70 ++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/backend/src/emails/sendEmailVariants.test.ts b/backend/src/emails/sendEmailVariants.test.ts index 858b6426b..dd3c979dd 100644 --- a/backend/src/emails/sendEmailVariants.test.ts +++ b/backend/src/emails/sendEmailVariants.test.ts @@ -12,6 +12,7 @@ import { sendContributionRejectedEmail, sendResetPasswordEmail, sendTransactionLinkRedeemedEmail, + sendTransactionReceivedEmail, } from './sendEmailVariants' import { sendEmailTranslated } from './sendEmailTranslated' @@ -551,4 +552,73 @@ describe('sendEmailVariants', () => { }) }) }) + + describe('sendTransactionReceivedEmail', () => { + beforeAll(async () => { + result = await sendTransactionReceivedEmail({ + firstName: 'Peter', + lastName: 'Lustig', + email: 'peter@lustig.de', + language: 'en', + senderFirstName: 'Bibi', + senderLastName: 'Bloxberg', + senderEmail: 'bibi@bloxberg.de', + transactionAmount: new Decimal(37.4), + }) + }) + + describe('calls "sendEmailTranslated"', () => { + it('with expected parameters', () => { + expect(sendEmailTranslated).toBeCalledWith({ + receiver: { + to: 'Peter Lustig ', + }, + template: 'transactionReceived', + locals: { + firstName: 'Peter', + lastName: 'Lustig', + locale: 'en', + senderFirstName: 'Bibi', + senderLastName: 'Bloxberg', + senderEmail: 'bibi@bloxberg.de', + transactionAmount: '37.40', + overviewURL: CONFIG.EMAIL_LINK_OVERVIEW, + }, + }) + }) + + it('has expected result', () => { + expect(result).toMatchObject({ + envelope: { + from: 'info@gradido.net', + to: ['peter@lustig.de'], + }, + message: expect.any(String), + originalMessage: expect.objectContaining({ + to: 'Peter Lustig ', + from: 'Gradido (nicht antworten) ', + attachments: [], + subject: 'Gradido: You have received Gradidos', + html: expect.any(String), + text: expect.stringContaining('GRADIDO: YOU HAVE RECEIVED GRADIDOS'), + }), + }) + expect(result.originalMessage.html).toContain('') + expect(result.originalMessage.html).toContain('') + expect(result.originalMessage.html).toContain( + 'Gradido: You have received Gradidos', + ) + expect(result.originalMessage.html).toContain('>Gradido: You have received Gradidos') + expect(result.originalMessage.html).toContain('Hello Peter Lustig') + expect(result.originalMessage.html).toContain( + 'You have just received 37.40 GDD from Bibi Bloxberg (bibi@bloxberg.de).', + ) + expect(result.originalMessage.html).toContain( + `You can find transaction details in your Gradido account: ${CONFIG.EMAIL_LINK_OVERVIEW}`, + ) + expect(result.originalMessage.html).toContain('Please do not reply to this email!') + expect(result.originalMessage.html).toContain('Kind regards,
your Gradido team') + }) + }) + }) })