mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
* Abstracted paypal logic from controller. Added intial tests * Added checkout tests * Added checkout success test * Added subscribe test * Added subscribeSuccess tests * Added subscribeCancel tests * Added ipn tests * Fixed broken test * Added integration tests and fixed linting issues * Added errors for paypal checkout success integration test * Removed extra test * Removed pending status from subscribe cancel test * Added more error checking and tests * Fixed lint issues
41 lines
1.0 KiB
JavaScript
41 lines
1.0 KiB
JavaScript
import {
|
|
generateUser,
|
|
} from '../../../../../helpers/api-integration/v3';
|
|
import paypalPayments from '../../../../../../website/server/libs/paypalPayments';
|
|
|
|
describe('payments : paypal #checkout', () => {
|
|
let endpoint = '/paypal/checkout';
|
|
let user;
|
|
|
|
beforeEach(async () => {
|
|
user = await generateUser();
|
|
});
|
|
|
|
describe('success', () => {
|
|
let checkoutStub;
|
|
|
|
beforeEach(async () => {
|
|
checkoutStub = sinon.stub(paypalPayments, 'checkout').returnsPromise().resolves('/');
|
|
});
|
|
|
|
afterEach(() => {
|
|
paypalPayments.checkout.restore();
|
|
});
|
|
|
|
it('creates a purchase link', 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.get(endpoint);
|
|
|
|
expect(checkoutStub).to.be.calledOnce;
|
|
expect(checkoutStub.args[0][0].gift).to.eql(undefined);
|
|
});
|
|
});
|
|
});
|