Skip to content

Commit

Permalink
Fix of stripe purchases integration tests (#62)
Browse files Browse the repository at this point in the history
* Attempt to fix integration tests

* Fix of stripe purchases integration tests
  • Loading branch information
SpertsyanKM authored Aug 15, 2023
1 parent d193cc6 commit 2a74f31
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 30 deletions.
50 changes: 25 additions & 25 deletions sdk/src/__integrationTests__/apiV3/PurchasesService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ describe('purchases tests', function () {

const purchased = getCurrentTs();
const purchaseCoreData: PurchaseCoreData = {
currency: 'USD',
price: '21.49',
currency: 'EUR',
price: '5',
purchased,
};
const stripeStoreData: StripeStoreData = {
productId: 'prod_LkgDHk3f9Z9qb3',
subscriptionId: 'sub_1N6Z7sL9K6ILzohYE49VAPcq'
productId: 'prod_OSEKoJ3z29ArRM',
subscriptionId: 'sub_1NfJsSHj4b8RrJvc78ALkOzh'
};

const data = {
Expand Down Expand Up @@ -57,12 +57,12 @@ describe('purchases tests', function () {
await userService.createUser(userId);

const purchaseCoreData: PurchaseCoreData = {
currency: 'USD',
price: '21.49',
currency: 'EUR',
price: '5',
};
const stripeStoreData: StripeStoreData = {
productId: 'prod_LkgDHk3f9Z9qb3',
subscriptionId: 'sub_1N6Z7sL9K6ILzohYE49VAPcq'
productId: 'prod_OSEKoJ3z29ArRM',
subscriptionId: 'sub_1NfJsSHj4b8RrJvc78ALkOzh'
};

const data = {
Expand All @@ -88,13 +88,13 @@ describe('purchases tests', function () {
const userId = 'testUidForPurchase' + Date.now();

const purchaseCoreData: PurchaseCoreData = {
currency: 'USD',
price: '21.49',
currency: 'EUR',
price: '5',
purchased: getCurrentTs(),
};
const stripeStoreData: StripeStoreData = {
productId: 'prod_LkgDHk3f9Z9qb3',
subscriptionId: 'sub_1N6Z7sL9K6ILzohYE49VAPcq'
productId: 'prod_OSEKoJ3z29ArRM',
subscriptionId: 'sub_1NfJsSHj4b8RrJvc78ALkOzh'
};

const data = {
Expand All @@ -104,8 +104,8 @@ describe('purchases tests', function () {

// when and then
await expectQonversionErrorAsync(
QonversionErrorCode.UserNotFound,
'Qonversion user not found. Id: ' + userId,
QonversionErrorCode.BackendError,
'Qonversion API returned an error. Response code 404, message: User not found',
async () => {
await purchasesService.sendStripePurchase(userId, data);
},
Expand All @@ -117,12 +117,12 @@ describe('purchases tests', function () {
await userService.createUser(userId);

const purchaseCoreData: PurchaseCoreData = {
currency: 'USD',
price: '21.49',
currency: 'EUR',
price: '5',
purchased: getCurrentTs(),
};
const stripeStoreData: StripeStoreData = {
productId: 'prod_LkgDHk3f9Z9qb3',
productId: 'prod_OSEKoJ3z29ArRM',
subscriptionId: 'incorrect subscription id'
};

Expand All @@ -146,13 +146,13 @@ describe('purchases tests', function () {
await userService.createUser(userId);

const purchaseCoreData: PurchaseCoreData = {
currency: 'USD',
price: '21,49',
currency: 'EUR',
price: '5,01',
purchased: getCurrentTs(),
};
const stripeStoreData: StripeStoreData = {
productId: 'prod_LkgDHk3f9Z9qb3',
subscriptionId: 'sub_1N6Z7sL9K6ILzohYE49VAPcq'
productId: 'prod_OSEKoJ3z29ArRM',
subscriptionId: 'sub_1NfJsSHj4b8RrJvc78ALkOzh'
};

const data = {
Expand All @@ -175,13 +175,13 @@ describe('purchases tests', function () {
await userService.createUser(userId);

const purchaseCoreData: PurchaseCoreData = {
currency: 'USDDD',
price: '21.49',
currency: 'EURRR',
price: '5',
purchased: getCurrentTs(),
};
const stripeStoreData: StripeStoreData = {
productId: 'prod_LkgDHk3f9Z9qb3',
subscriptionId: 'sub_1N6Z7sL9K6ILzohYE49VAPcq'
productId: 'prod_OSEKoJ3z29ArRM',
subscriptionId: 'sub_1NfJsSHj4b8RrJvc78ALkOzh'
};

const data = {
Expand Down
5 changes: 0 additions & 5 deletions sdk/src/internal/purchases/PurchaseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {ApiInteractor, RequestConfigurator} from '../network';
import {camelCaseKeys} from '../utils/objectUtils';
import {QonversionError} from '../../exception/QonversionError';
import {QonversionErrorCode} from '../../exception/QonversionErrorCode';
import {HTTP_CODE_NOT_FOUND} from '../network/constants';

export class PurchaseServiceImpl implements PurchasesService {
private readonly requestConfigurator: RequestConfigurator;
Expand All @@ -23,10 +22,6 @@ export class PurchaseServiceImpl implements PurchasesService {
return camelCaseKeys(response.data);
}

if (response.code == HTTP_CODE_NOT_FOUND) {
throw new QonversionError(QonversionErrorCode.UserNotFound, `Id: ${userId}`);
}

const errorMessage = `Response code ${response.code}, message: ${response.message}`;
throw new QonversionError(QonversionErrorCode.BackendError, errorMessage);
}
Expand Down

0 comments on commit 2a74f31

Please sign in to comment.