mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
* Support subscription payment through Google Play Store * minor fixes to iap subscriptions * Support subscription payment through Google Play Store * minor fixes to iap subscriptions * revert change to test * add unit tests for google payments * add integration tests for google payments * change config formatting for play api * fix typo in file name * fix typo in example config * Improve google payment tests * fix linter errors
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import {generateUser} from '../../../../../helpers/api-integration/v3';
|
|
import googlePayments from '../../../../../../website/server/libs/googlePayments';
|
|
|
|
describe('payments : google #cancelSubscribe', () => {
|
|
let endpoint = '/iap/android/subscribe/cancel';
|
|
let user;
|
|
|
|
beforeEach(async () => {
|
|
user = await generateUser();
|
|
});
|
|
|
|
describe('success', () => {
|
|
let cancelStub;
|
|
|
|
beforeEach(async () => {
|
|
cancelStub = sinon.stub(googlePayments, 'cancelSubscribe').returnsPromise().resolves({});
|
|
});
|
|
|
|
afterEach(() => {
|
|
googlePayments.cancelSubscribe.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.get(endpoint);
|
|
|
|
expect(cancelStub).to.be.calledOnce;
|
|
expect(cancelStub.args[0][0]._id).to.eql(user._id);
|
|
expect(cancelStub.args[0][1]['x-api-key']).to.eql(user.apiToken);
|
|
expect(cancelStub.args[0][1]['x-api-user']).to.eql(user._id);
|
|
});
|
|
});
|
|
});
|