2017-01-22 16:59:47 +00:00
|
|
|
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,
|
|
|
|
|
});
|
|
|
|
|
|
2017-02-16 23:33:49 +00:00
|
|
|
await user.get(`${endpoint}?noRedirect=true`);
|
2017-01-22 16:59:47 +00:00
|
|
|
|
|
|
|
|
expect(checkoutStub).to.be.calledOnce;
|
|
|
|
|
expect(checkoutStub.args[0][0].gift).to.eql(undefined);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|