Skip to content

Commit

Permalink
feat(payment-stripe): update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegDO committed Feb 15, 2024
1 parent 68e6042 commit cc87f86
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,71 @@ describe('services/calculation', () => {
sandbox.restore();
});

describe('getPaymentIntentFees', () => {
it('should correctly compute payment intent fees', async () => {
const expectedResult = {
platformUnitFee: 0,
extraReceiverUnitRevenue: 0,
stripeUnitFee: 61,
receiverAdditionalFee: 0,
receiverUnitRevenue: 1000,
senderAdditionalFee: 0,
userUnitAmount: 1061,
};

expect(
await Calculation.getPaymentIntentFees({
feesPayer: TransactionRole.SENDER,
entityUnitCost: 1000,
}),
).to.deep.equal(expectedResult);
});

it('should correctly compute payment intent fees with application fees', async () => {
const expectedResult = {
platformUnitFee: 30,
extraReceiverUnitRevenue: 0,
stripeUnitFee: 62,
receiverAdditionalFee: 0,
receiverUnitRevenue: 1000,
senderAdditionalFee: 0,
userUnitAmount: 1092,
};

expect(
await Calculation.getPaymentIntentFees({
feesPayer: TransactionRole.SENDER,
entityUnitCost: 1000,
applicationPaymentPercent: 3,
}),
).to.deep.equal(expectedResult);
});

it('should correctly compute payment intent fees with application and receiver additional fees', async () => {
const expectedResult = {
platformUnitFee: 30,
extraReceiverUnitRevenue: 0,
stripeUnitFee: 62,
receiverAdditionalFee: 60,
receiverUnitRevenue: 940,
senderAdditionalFee: 0,
userUnitAmount: 1092,
};

expect(
await Calculation.getPaymentIntentFees({
feesPayer: TransactionRole.SENDER,
entityUnitCost: 1000,
applicationPaymentPercent: 3,
additionalFeesPercent: {
receiver: 6,
sender: 0,
},
}),
).to.deep.equal(expectedResult);
});
});

describe('getStripeFeeAndProcessingAmount', () => {
it('should correctly calculate stripe fee and processing amount for sender', async () => {
expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from '@__mocks__/stripe';
import * as remoteConfig from '@config/remote';
import StripeAccountTypes from '@constants/stripe-account-types';
import TransactionRole from '@constants/transaction-role';
import OriginalStripe from '@services/payment-gateway/stripe';

interface IStripeMockParams {
Expand Down Expand Up @@ -327,69 +326,6 @@ describe('services/payment-gateway/stripe', () => {
);
});

it('should correctly compute payment intent fees', async () => {
const expectedResult = {
platformUnitFee: 0,
extraReceiverUnitRevenue: 0,
stripeUnitFee: 61,
receiverAdditionalFee: 0,
receiverUnitRevenue: 1000,
senderAdditionalFee: 0,
userUnitAmount: 1061,
};

expect(
await service.getPaymentIntentFees({
feesPayer: TransactionRole.SENDER,
entityUnitCost: 1000,
}),
).to.deep.equal(expectedResult);
});

it('should correctly compute payment intent fees with application fees', async () => {
const expectedResult = {
platformUnitFee: 30,
extraReceiverUnitRevenue: 0,
stripeUnitFee: 62,
receiverAdditionalFee: 0,
receiverUnitRevenue: 1000,
senderAdditionalFee: 0,
userUnitAmount: 1092,
};

expect(
await service.getPaymentIntentFees({
feesPayer: TransactionRole.SENDER,
entityUnitCost: 1000,
applicationPaymentPercent: 3,
}),
).to.deep.equal(expectedResult);
});

it('should correctly compute payment intent fees with application and receiver additional fees', async () => {
const expectedResult = {
platformUnitFee: 30,
extraReceiverUnitRevenue: 0,
stripeUnitFee: 62,
receiverAdditionalFee: 60,
receiverUnitRevenue: 940,
senderAdditionalFee: 0,
userUnitAmount: 1092,
};

expect(
await service.getPaymentIntentFees({
feesPayer: TransactionRole.SENDER,
entityUnitCost: 1000,
applicationPaymentPercent: 3,
additionalFeesPercent: {
receiver: 6,
sender: 0,
},
}),
).to.deep.equal(expectedResult);
});

it('should correctly set payment method', async () => {
StripeInstanceParamStub.value(
stripeMock({
Expand Down

0 comments on commit cc87f86

Please sign in to comment.