Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kewitz committed Mar 6, 2025
1 parent 2748688 commit 6bedf47
Show file tree
Hide file tree
Showing 3 changed files with 3,480 additions and 819 deletions.
16 changes: 8 additions & 8 deletions test/server/paymentProviders/transferwise/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ describe('server/paymentProviders/transferwise/index', () => {
getBatchGroup.resolves({ id: batchGroupId, version: 1, transferIds: [800], status: 'NEW' });
createBatchGroupTransfer.resolves({ id: 800 });
completeBatchGroup.resolves({ id: batchGroupId, version: 2, status: 'COMPLETED' });
response = await transferwise.payExpensesBatchGroup(host, [expense]);
response = await transferwise.payExpensesBatchGroup({ host, expenses: [expense] });
});

it('should complete and fund batch group', () => {
Expand All @@ -448,7 +448,7 @@ describe('server/paymentProviders/transferwise/index', () => {
});

it('should retry funding if batchGroup is completed but not paid for', async () => {
response = await transferwise.payExpensesBatchGroup(host, [expense]);
response = await transferwise.payExpensesBatchGroup({ host, expenses: [expense] });

expect(fundBatchGroup.callCount).to.be.equal(2);
expect(fundBatchGroup.secondCall).to.have.nested.property('args[2]', batchGroupId);
Expand All @@ -457,15 +457,15 @@ describe('server/paymentProviders/transferwise/index', () => {

it('should retry batchGroup if OTT token is provided', async () => {
fundBatchGroup.resolves();
await transferwise.payExpensesBatchGroup(host, undefined, ottToken);
await transferwise.approveExpenseBatchGroupPayment({ host, x2faApproval: ottToken });

expect(fundBatchGroup.getCall(2)).to.have.nested.property('args[2]', batchGroupId);
expect(fundBatchGroup.getCall(2)).to.have.nested.property('args[3]', ottToken);
});

it('should fail if batchGroup status === COMPLETED and alreadyPaid is true', async () => {
getBatchGroup.resolves({ id: batchGroupId, version: 1, transferIds: [], status: 'COMPLETED', alreadyPaid: true });
const call = transferwise.payExpensesBatchGroup(host, [expense]);
const call = transferwise.payExpensesBatchGroup({ host, expenses: [expense] });
await expect(call).to.be.eventually.rejectedWith(
Error,
`Can not pay batch group, existing batch group was already paid`,
Expand All @@ -474,7 +474,7 @@ describe('server/paymentProviders/transferwise/index', () => {

it('should fail if batchGroup was already cancelled', async () => {
getBatchGroup.resolves({ id: batchGroupId, version: 1, transferIds: [], status: 'CANCELLED' });
const call = transferwise.payExpensesBatchGroup(host, [expense]);
const call = transferwise.payExpensesBatchGroup({ host, expenses: [expense] });
await expect(call).to.be.eventually.rejectedWith(
Error,
`Can not pay batch group, existing batch group was cancelled`,
Expand All @@ -483,7 +483,7 @@ describe('server/paymentProviders/transferwise/index', () => {

it('should fail if batchGroup does not contain every expense', async () => {
getBatchGroup.resolves({ id: batchGroupId, version: 1, transferIds: [], status: 'NEW' });
const call = transferwise.payExpensesBatchGroup(host, [expense]);
const call = transferwise.payExpensesBatchGroup({ host, expenses: [expense] });
await expect(call).to.be.eventually.rejectedWith(
Error,
`Batch group ${batchGroupId} does not include expense ${expense.id}`,
Expand All @@ -509,7 +509,7 @@ describe('server/paymentProviders/transferwise/index', () => {
},
});
getBatchGroup.resolves({ id: batchGroupId, version: 1, transferIds: [800], status: 'NEW' });
const call = transferwise.payExpensesBatchGroup(host, [expiredExpense]);
const call = transferwise.payExpensesBatchGroup({ host, expenses: [expiredExpense] });
await expect(call).to.be.eventually.rejectedWith(
Error,
`Expense ${expiredExpense.id} quote expired. Unschedule expense and try again`,
Expand All @@ -535,7 +535,7 @@ describe('server/paymentProviders/transferwise/index', () => {
},
});
getBatchGroup.resolves({ id: batchGroupId, version: 1, transferIds: [800, 546], status: 'NEW' });
const call = transferwise.payExpensesBatchGroup(host, [expense]);
const call = transferwise.payExpensesBatchGroup({ host, expenses: [expense] });
await expect(call).to.be.eventually.rejectedWith(
Error,
`Expenses requested do not match the transfers added to batch group ${batchGroupId}`,
Expand Down
Loading

0 comments on commit 6bedf47

Please sign in to comment.