Skip to content

Commit 02d13a2

Browse files
committed
fix (tests)
1 parent 158f2ef commit 02d13a2

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/resolvers/billingNew.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,11 @@ export default {
177177
paymentAmount = pricing.finalAmount;
178178
paymentPromoChecksum = buildPaymentPromoData(pricing.promoCode._id.toString(), promoUtm);
179179
composePaymentPromo = {
180+
id: pricing.promoCode._id.toString(),
181+
benefitType: pricing.benefitType,
180182
originalAmount: pricing.originalAmount,
181183
finalAmount: pricing.finalAmount,
184+
discountAmount: pricing.discountAmount,
182185
};
183186
} catch (error) {
184187
throwPromoCodeGraphQLError(error);

test/billing/cloudpayments.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,9 +719,14 @@ describe('CloudPaymentsWebhooks', () => {
719719

720720
expect(changePlan).toHaveBeenCalledWith(plan._id);
721721
expect(createUsage).toHaveBeenCalledWith(expect.objectContaining({
722-
promoCodeId: promoCode._id.toString(),
722+
promoCodeId: promoCode._id,
723723
userId,
724-
plan: expect.objectContaining({ _id: plan._id }),
724+
workspaceId: expect.any(ObjectId),
725+
planId: plan._id,
726+
benefitType: 'percent_discount',
727+
originalAmount: 1000,
728+
finalAmount: 750,
729+
discountAmount: 250,
725730
}));
726731
expect(publish).toHaveBeenCalled();
727732
expect(sendNotification).toHaveBeenCalledWith(

test/services/promoCodeService.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function createService(promoCode: any, options: {
4343
return new PromoCodeService({
4444
promoCodesFactory: {
4545
findByValue: jest.fn().mockResolvedValue(promoCode),
46+
findOne: jest.fn().mockResolvedValue(promoCode),
4647
},
4748
promoCodeUsagesFactory: {
4849
countByPromoCodeId: jest.fn().mockResolvedValue(options.totalUses ?? 0),

0 commit comments

Comments
 (0)