mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
test contribution link redeem
This commit is contained in:
parent
9493ed58d9
commit
09c5aff33e
@ -26,6 +26,9 @@ import Decimal from 'decimal.js-light'
|
||||
import { GraphQLError } from 'graphql'
|
||||
import { TRANSACTIONS_LOCK } from '@/util/TRANSACTIONS_LOCK'
|
||||
import { logger } from '@test/testSetup'
|
||||
import { EventType } from '@/event/Event'
|
||||
import { Event as DbEvent } from '@entity/Event'
|
||||
import { UserContact } from '@entity/UserContact'
|
||||
|
||||
// mock semaphore to allow use fake timers
|
||||
jest.mock('@/util/TRANSACTIONS_LOCK')
|
||||
@ -432,6 +435,24 @@ describe('TransactionLinkResolver', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('stores the CONTRIBUTION_LINK_REDEEM event in the database', async () => {
|
||||
const userConatct = await UserContact.findOneOrFail(
|
||||
{ email: 'bibi@bloxberg.de' },
|
||||
{ relations: ['user'] },
|
||||
)
|
||||
expect(DbEvent.find()).resolves.toContainEqual(
|
||||
expect.objectContaining({
|
||||
type: EventType.CONTRIBUTION_LINK_REDEEM,
|
||||
affectedUserId: userConatct.user.id,
|
||||
actingUserId: userConatct.user.id,
|
||||
involvedTransactionId: expect.any(Number),
|
||||
involvedContributionId: expect.any(Number),
|
||||
involvedContributionLinkId: contributionLink?.id,
|
||||
amount: contributionLink?.amount,
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('does not allow the user to redeem the contribution link a second time on the same day', async () => {
|
||||
jest.clearAllMocks()
|
||||
await expect(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user