mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
fix(payments): correct more tests
This commit is contained in:
@@ -94,6 +94,7 @@ describe('Apple Payments', () => {
|
||||
productId: 'badProduct',
|
||||
transactionId: token,
|
||||
}]);
|
||||
paymentBuyGemsStub.restore();
|
||||
|
||||
await expect(applePayments.verifyPurchase({ user, receipt, headers }))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
@@ -102,6 +103,7 @@ describe('Apple Payments', () => {
|
||||
message: applePayments.constants.RESPONSE_INVALID_ITEM,
|
||||
});
|
||||
|
||||
paymentBuyGemsStub = sinon.stub(payments, 'buySkuItem').resolves({});
|
||||
user.canGetGems.restore();
|
||||
});
|
||||
|
||||
@@ -151,10 +153,10 @@ describe('Apple Payments', () => {
|
||||
expect(paymentBuyGemsStub).to.be.calledOnce;
|
||||
expect(paymentBuyGemsStub).to.be.calledWith({
|
||||
user,
|
||||
paymentMethod: applePayments.constants.PAYMENT_METHOD_APPLE,
|
||||
gemsBlock: common.content.gems[gemTest.gemsBlock],
|
||||
headers,
|
||||
gift: undefined,
|
||||
paymentMethod: applePayments.constants.PAYMENT_METHOD_APPLE,
|
||||
sku: gemTest.productId,
|
||||
headers,
|
||||
});
|
||||
expect(user.canGetGems).to.be.calledOnce;
|
||||
user.canGetGems.restore();
|
||||
|
||||
@@ -61,6 +61,7 @@ describe('Google Payments', () => {
|
||||
it('should throw an error if productId is invalid', async () => {
|
||||
receipt = `{"token": "${token}", "productId": "invalid"}`;
|
||||
|
||||
paymentBuyGemsStub.restore();
|
||||
await expect(googlePayments.verifyPurchase({
|
||||
user, receipt, signature, headers,
|
||||
}))
|
||||
@@ -69,6 +70,7 @@ describe('Google Payments', () => {
|
||||
name: 'BadRequest',
|
||||
message: googlePayments.constants.RESPONSE_INVALID_ITEM,
|
||||
});
|
||||
paymentBuyGemsStub = sinon.stub(payments, 'buySkuItem').resolves({});
|
||||
});
|
||||
|
||||
it('should throw an error if user cannot purchase gems', async () => {
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('payments/skuItems', () => {
|
||||
});
|
||||
|
||||
describe('#gryphatrice', () => {
|
||||
const sku = 'com.habitrpg.android.habitica.iap.pets.gryphatrice-jubilant';
|
||||
const sku = 'Pet-Gryphatrice-Jubilant';
|
||||
it('returns true during birthday week', () => {
|
||||
clock = sinon.useFakeTimers(new Date('2023-01-29'));
|
||||
expect(canBuySkuItem(sku, user)).to.be.true;
|
||||
|
||||
Reference in New Issue
Block a user