Skip to content

Commit

Permalink
update recurring payments bit
Browse files Browse the repository at this point in the history
rPlease enter the commit message for your changes. Lines starting
  • Loading branch information
lailien3 committed Jan 3, 2025
1 parent 6e10d88 commit e5ca3fa
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,11 @@ describe('transaction service', () => {
callingArgs.transaction = JSON.parse(JSON.stringify(transaction))
})
const mockRecord = mockFinalisedTransactionRecord()
AwsMock.DynamoDB.DocumentClient.__setResponse('get', { Item: mockRecord })
const immutableMockRecord = JSON.parse(JSON.stringify(mockRecord))
docClient.send.mockResolvedValueOnce({ Item: mockRecord })
await processQueue({ id: mockRecord.id })
// jest.fn args aren't immutable and transaction is changed in processQueue, so we use our clone that hasn't changed
expect(callingArgs.transaction).toEqual(mockRecord)
expect(callingArgs.transaction).toEqual(immutableMockRecord)
})

it('passes permission to generateRecurringPaymentRecord', async () => {
Expand All @@ -411,7 +412,7 @@ describe('transaction service', () => {
for (const key of keysToCopy) {
expectedPermissionData[key] = mockRecord.permissions[0][key]
}
AwsMock.DynamoDB.DocumentClient.__setResponse('get', { Item: mockRecord })
docClient.send.mockResolvedValueOnce({ Item: mockRecord })

await processQueue({ id: mockRecord.id })

Expand All @@ -422,7 +423,7 @@ describe('transaction service', () => {
const rprSymbol = Symbol('rpr')
const finalisedTransaction = mockFinalisedTransactionRecord()
generateRecurringPaymentRecord.mockReturnValueOnce(rprSymbol)
AwsMock.DynamoDB.DocumentClient.__setResponse('get', { Item: finalisedTransaction })
docClient.send.mockResolvedValueOnce({ Item: finalisedTransaction })
await processQueue({ id: finalisedTransaction.id })
expect(processRecurringPayment).toHaveBeenCalledWith(rprSymbol, expect.any(Contact))
})
Expand Down

0 comments on commit e5ca3fa

Please sign in to comment.