Skip to content

Commit ff4c1fa

Browse files
committed
feat: gql resolver test changes
1 parent f7cd4a0 commit ff4c1fa

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

packages/backend/src/graphql/resolvers/liquidity.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import {
5151
import { GraphQLErrorCode } from '../errors'
5252
import { Tenant } from '../../tenants/model'
5353
import { createTenant } from '../../tests/tenant'
54+
import { faker } from '@faker-js/faker'
5455

5556
describe('Liquidity Resolvers', (): void => {
5657
let deps: IocContract<AppServices>
@@ -3493,6 +3494,9 @@ describe('Liquidity Resolvers', (): void => {
34933494

34943495
test('Can deposit account liquidity', async (): Promise<void> => {
34953496
const depositSpy = jest.spyOn(accountingService, 'createDeposit')
3497+
const dataToTransmit = JSON.stringify({
3498+
data: faker.internet.email()
3499+
})
34963500
const response = await appContainer.apolloClient
34973501
.mutate({
34983502
mutation: gql`
@@ -3507,7 +3511,8 @@ describe('Liquidity Resolvers', (): void => {
35073511
variables: {
35083512
input: {
35093513
outgoingPaymentId: outgoingPayment.id,
3510-
idempotencyKey: uuid()
3514+
idempotencyKey: uuid(),
3515+
dataToTransmit
35113516
}
35123517
}
35133518
})
@@ -3529,6 +3534,13 @@ describe('Liquidity Resolvers', (): void => {
35293534
await expect(
35303535
accountingService.getBalance(outgoingPayment.id)
35313536
).resolves.toEqual(outgoingPayment.debitAmount.value)
3537+
await expect(
3538+
OutgoingPayment.query(knex).findById(outgoingPayment.id)
3539+
).resolves.toEqual(
3540+
expect.objectContaining({
3541+
dataToTransmit
3542+
})
3543+
)
35323544
})
35333545

35343546
test("Can't deposit for non-existent outgoing payment id", async (): Promise<void> => {

packages/backend/src/graphql/resolvers/outgoing_payment.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,47 @@ describe('OutgoingPayment Resolvers', (): void => {
748748
)
749749
}
750750
})
751+
752+
test('dataToTransmit', async (): Promise<void> => {
753+
const walletAddress = await createWalletAddress(deps, {
754+
assetId: asset.id,
755+
tenantId: asset.tenantId
756+
})
757+
payment = await createPayment({
758+
walletAddressId: walletAddress.id,
759+
tenantId: walletAddress.tenantId
760+
})
761+
const dataToTransmit = JSON.stringify({ data: faker.internet.email() })
762+
await outgoingPaymentService.fund({
763+
id: payment.id,
764+
tenantId: payment.tenantId,
765+
amount: payment.debitAmount.value,
766+
transferId: uuid(),
767+
dataToTransmit
768+
})
769+
770+
const query = await appContainer.apolloClient
771+
.query({
772+
query: gql`
773+
query OutgoingPayment($paymentId: String!) {
774+
outgoingPayment(id: $paymentId) {
775+
id
776+
dataToTransmit
777+
}
778+
}
779+
`,
780+
variables: {
781+
paymentId: payment.id
782+
}
783+
})
784+
.then((query): OutgoingPayment => query.data?.outgoingPayment)
785+
786+
expect(query).toEqual({
787+
id: payment.id,
788+
dataToTransmit,
789+
__typename: 'OutgoingPayment'
790+
})
791+
})
751792
})
752793

753794
describe('Mutation.createOutgoingPayment', (): void => {

0 commit comments

Comments
 (0)