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 17, 2021
1 parent f1176da commit d95ef25
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
18 changes: 16 additions & 2 deletions test/server/graphql/v2/mutation/ExpenseMutations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,15 +942,29 @@ describe('server/graphql/v2/mutation/ExpenseMutations', () => {
describe('With transferwise', () => {
const fee = 1.74;
let getTemporaryQuote, expense;
const quote = {
payOut: 'BANK_TRANSFER',
paymentOptions: [
{
payInProduct: 'BALANCE',
fee: { total: fee },
payIn: 'BALANCE',
sourceCurrency: 'USD',
targetCurrency: 'EUR',
payOut: 'BANK_TRANSFER',
disabled: false,
},
],
};

before(async () => {
// Updates the collective balance and pay the expense
await fakeTransaction({ type: 'CREDIT', CollectiveId: collective.id, amount: 15000000 });
});

beforeEach(() => {
getTemporaryQuote = sandbox.stub(paymentProviders.transferwise, 'getTemporaryQuote').resolves({ fee });
sandbox.stub(paymentProviders.transferwise, 'payExpense').resolves({ quote: { fee } });
getTemporaryQuote = sandbox.stub(paymentProviders.transferwise, 'getTemporaryQuote').resolves(quote);
sandbox.stub(paymentProviders.transferwise, 'payExpense').resolves({ quote });
});

beforeEach(async () => {
Expand Down
25 changes: 22 additions & 3 deletions test/server/paymentProviders/transferwise/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,32 @@ describe('server/paymentProviders/transferwise/index', () => {
const sandbox = sinon.createSandbox();
const quote = {
id: 1234,
source: 'USD',
target: 'EUR',
sourceCurrency: 'USD',
targetCurrency: 'EUR',
sourceAmount: 101.14,
targetAmount: 90.44,
rate: 0.9044,
fee: 1.14,
payOut: 'BANK_TRANSFER',
paymentOptions: [
{
formattedEstimatedDelivery: 'by March 18th',
estimatedDeliveryDelays: [],
allowedProfileTypes: ['PERSONAL', 'BUSINESS'],
payInProduct: 'BALANCE',
feePercentage: 0.0038,
estimatedDelivery: '2021-03-18T12:45:00Z',
fee: { transferwise: 3.79, payIn: 0, discount: 0, total: 3.79, priceSetId: 134, partner: 0 },
payIn: 'BALANCE',
sourceAmount: 101.14,
targetAmount: 90.44,
sourceCurrency: 'USD',
targetCurrency: 'EUR',
payOut: 'BANK_TRANSFER',
disabled: false,
},
],
};

let createQuote,
createRecipientAccount,
createTransfer,
Expand Down

0 comments on commit d95ef25

Please sign in to comment.