From 225119c8ab1833f005a49e03e9d9ab518b5b572e Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 7 Nov 2022 10:10:28 +0100 Subject: [PATCH] Test that the email is build correctly. --- .../sendContributionRejectedEmail.test.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 backend/src/mailer/sendContributionRejectedEmail.test.ts diff --git a/backend/src/mailer/sendContributionRejectedEmail.test.ts b/backend/src/mailer/sendContributionRejectedEmail.test.ts new file mode 100644 index 000000000..fb044692b --- /dev/null +++ b/backend/src/mailer/sendContributionRejectedEmail.test.ts @@ -0,0 +1,38 @@ +import Decimal from 'decimal.js-light' +import { sendContributionRejectedEmail } from './sendContributionRejectedEmail' +import { sendEMail } from './sendEMail' + +jest.mock('./sendEMail', () => { + return { + __esModule: true, + sendEMail: jest.fn(), + } +}) + +describe('sendContributionConfirmedEmail', () => { + beforeEach(async () => { + await sendContributionRejectedEmail({ + senderFirstName: 'Peter', + senderLastName: 'Lustig', + recipientFirstName: 'Bibi', + recipientLastName: 'Bloxberg', + recipientEmail: 'bibi@bloxberg.de', + contributionMemo: 'Vielen herzlichen Dank für den neuen Hexenbesen!', + contributionAmount: new Decimal(200.0), + overviewURL: 'http://localhost/overview', + }) + }) + + it('calls sendEMail', () => { + expect(sendEMail).toBeCalledWith({ + to: 'Bibi Bloxberg ', + subject: 'Schöpfung wurde abgelehnt', + text: + expect.stringContaining('Hallo Bibi Bloxberg') && + expect.stringContaining( + 'Dein Gradido Schöpfungsantrag "Vielen herzlichen Dank für den neuen Hexenbesen!" wurde soeben von Peter Lustig abgelehnt.', + ) && + expect.stringContaining('Link zu deinem Konto: http://localhost/overview'), + }) + }) +})