From 72f85c0d598799f959262f4ca8ad1da29b38e4e1 Mon Sep 17 00:00:00 2001 From: elweyn Date: Mon, 12 Sep 2022 11:35:01 +0200 Subject: [PATCH] Add test for sendContributionConfirmedEmail. --- .../sendContributionConfirmedEmail.test.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 backend/src/mailer/sendContributionConfirmedEmail.test.ts diff --git a/backend/src/mailer/sendContributionConfirmedEmail.test.ts b/backend/src/mailer/sendContributionConfirmedEmail.test.ts new file mode 100644 index 000000000..7fcb7c993 --- /dev/null +++ b/backend/src/mailer/sendContributionConfirmedEmail.test.ts @@ -0,0 +1,39 @@ +import Decimal from 'decimal.js-light' +import { sendContributionConfirmedEmail } from './sendContributionConfirmedEmail' +import { sendEMail } from './sendEMail' + +jest.mock('./sendEMail', () => { + return { + __esModule: true, + sendEMail: jest.fn(), + } +}) + +describe('sendContributionConfirmedEmail', () => { + beforeEach(async () => { + await sendContributionConfirmedEmail({ + 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 bestätigt', + text: + expect.stringContaining('Hallo Bibi Bloxberg') && + expect.stringContaining( + 'Deine Gradido Schöpfungsantrag "Vielen herzlichen Dank für den neuen Hexenbesen!" wurde soeben bestätigt.', + ) && + expect.stringContaining('Betrag: 200,00 GDD') && + expect.stringContaining('Link zu deinem Konto: http://localhost/overview'), + }) + }) +})