fix(payments): address some test failures

This commit is contained in:
SabreCat
2023-01-22 22:30:48 -06:00
parent 0dfc8de300
commit f845bbd7a0
5 changed files with 17 additions and 17 deletions

View File

@@ -17,7 +17,7 @@ describe('Amazon Payments - Checkout', () => {
let closeOrderReferenceSpy;
let paymentBuyGemsStub;
let paymentCreateSubscritionStub;
let paymentCreateSubscriptionStub;
let amount = gemsBlock.price / 100;
function expectOrderReferenceSpy () {
@@ -85,8 +85,8 @@ describe('Amazon Payments - Checkout', () => {
paymentBuyGemsStub = sinon.stub(payments, 'buyGems');
paymentBuyGemsStub.resolves({});
paymentCreateSubscritionStub = sinon.stub(payments, 'createSubscription');
paymentCreateSubscritionStub.resolves({});
paymentCreateSubscriptionStub = sinon.stub(payments, 'createSubscription');
paymentCreateSubscriptionStub.resolves({});
sinon.stub(common, 'uuid').returns('uuid-generated');
sandbox.stub(gems, 'validateGiftMessage');
@@ -109,6 +109,7 @@ describe('Amazon Payments - Checkout', () => {
user,
paymentMethod,
headers,
sku: undefined,
};
if (gift) {
expectedArgs.gift = gift;
@@ -215,13 +216,14 @@ describe('Amazon Payments - Checkout', () => {
});
gift.member = receivingUser;
expect(paymentCreateSubscritionStub).to.be.calledOnce;
expect(paymentCreateSubscritionStub).to.be.calledWith({
expect(paymentCreateSubscriptionStub).to.be.calledOnce;
expect(paymentCreateSubscriptionStub).to.be.calledWith({
user,
paymentMethod: amzLib.constants.PAYMENT_METHOD_GIFT,
headers,
gift,
gemsBlock: undefined,
sku: undefined,
});
expectAmazonStubs();
});

View File

@@ -36,7 +36,7 @@ describe('Apple Payments', () => {
productId: 'com.habitrpg.ios.Habitica.21gems',
transactionId: token,
}]);
paymentBuyGemsStub = sinon.stub(payments, 'buyGems').resolves({});
paymentBuyGemsStub = sinon.stub(payments, 'buySkuItem').resolves({});
validateGiftMessageStub = sinon.stub(gems, 'validateGiftMessage');
});
@@ -45,7 +45,7 @@ describe('Apple Payments', () => {
iap.validate.restore();
iap.isValidated.restore();
iap.getPurchaseData.restore();
payments.buyGems.restore();
payments.buySkuItem.restore();
gems.validateGiftMessage.restore();
});
@@ -97,8 +97,8 @@ describe('Apple Payments', () => {
await expect(applePayments.verifyPurchase({ user, receipt, headers }))
.to.eventually.be.rejected.and.to.eql({
httpCode: 401,
name: 'NotAuthorized',
httpCode: 400,
name: 'BadRequest',
message: applePayments.constants.RESPONSE_INVALID_ITEM,
});

View File

@@ -31,7 +31,7 @@ describe('Google Payments', () => {
.resolves({});
iapIsValidatedStub = sinon.stub(iap, 'isValidated')
.returns(true);
paymentBuyGemsStub = sinon.stub(payments, 'buyGems').resolves({});
paymentBuyGemsStub = sinon.stub(payments, 'buySkuItem').resolves({});
validateGiftMessageStub = sinon.stub(gems, 'validateGiftMessage');
});
@@ -39,7 +39,7 @@ describe('Google Payments', () => {
iap.setup.restore();
iap.validate.restore();
iap.isValidated.restore();
payments.buyGems.restore();
payments.buySkuItem.restore();
gems.validateGiftMessage.restore();
});
@@ -65,8 +65,8 @@ describe('Google Payments', () => {
user, receipt, signature, headers,
}))
.to.eventually.be.rejected.and.to.eql({
httpCode: 401,
name: 'NotAuthorized',
httpCode: 400,
name: 'BadRequest',
message: googlePayments.constants.RESPONSE_INVALID_ITEM,
});
});

View File

@@ -9,7 +9,6 @@ import {
} from '../errors';
import { model as IapPurchaseReceipt } from '../../models/iapPurchaseReceipt';
import { model as User } from '../../models/user';
import { buySkuItem } from './skuItem';
const api = {};
@@ -62,7 +61,7 @@ api.verifyPurchase = async function verifyPurchase (options) {
userId: user._id,
});
await buySkuItem({ // eslint-disable-line no-await-in-loop
await payments.buySkuItem({ // eslint-disable-line no-await-in-loop
user,
gift,
paymentMethod: api.constants.PAYMENT_METHOD_APPLE,

View File

@@ -9,7 +9,6 @@ import {
import { model as IapPurchaseReceipt } from '../../models/iapPurchaseReceipt';
import { model as User } from '../../models/user';
import { validateGiftMessage } from './gems';
import { buySkuItem } from './skuItem';
const api = {};
@@ -62,7 +61,7 @@ api.verifyPurchase = async function verifyPurchase (options) {
userId: user._id,
});
await buySkuItem({ // eslint-disable-line no-await-in-loop
await payments.buySkuItem({ // eslint-disable-line no-await-in-loop
user,
gift,
paymentMethod: api.constants.PAYMENT_METHOD_GOOGLE,