mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-10-29 12:12:36 +01:00
45 lines
1.0 KiB
JavaScript
45 lines
1.0 KiB
JavaScript
import {
|
|
generateUser,
|
|
} from '../../../../../helpers/api-integration/v3';
|
|
import paypalPayments from '../../../../../../website/server/libs/payments/paypal';
|
|
|
|
describe('payments - paypal - #ipn', () => {
|
|
let endpoint = '/paypal/ipn';
|
|
let user;
|
|
|
|
beforeEach(async () => {
|
|
user = await generateUser();
|
|
});
|
|
|
|
it('verifies credentials', async () => {
|
|
let result = await user.post(endpoint);
|
|
expect(result).to.eql('OK');
|
|
});
|
|
|
|
describe('success', () => {
|
|
let ipnStub;
|
|
|
|
beforeEach(async () => {
|
|
ipnStub = sinon.stub(paypalPayments, 'ipn').resolves({});
|
|
});
|
|
|
|
afterEach(() => {
|
|
paypalPayments.ipn.restore();
|
|
});
|
|
|
|
it('makes a purchase', async () => {
|
|
user = await generateUser({
|
|
'profile.name': 'sender',
|
|
'purchased.plan.customerId': 'customer-id',
|
|
'purchased.plan.planId': 'basic_3mo',
|
|
'purchased.plan.lastBillingDate': new Date(),
|
|
balance: 2,
|
|
});
|
|
|
|
await user.post(endpoint);
|
|
|
|
expect(ipnStub).to.be.calledOnce;
|
|
});
|
|
});
|
|
});
|