File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
packages/billing/src/__tests__ Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -447,15 +447,17 @@ describe('grant-credits', () => {
447447 }
448448 const legacyReferralBonus = 500
449449
450+ // Mock db for calculateTotalLegacyReferralBonus (uses db directly, not tx)
451+ // This mock needs to return the referral query result for the legacy bonus calculation
450452 await mockModule ( '@codebuff/internal/db' , ( ) => ( {
451453 default : {
452454 select : ( ) => ( {
453455 from : ( ) => ( {
454- where : ( ) => ( {
455- orderBy : ( ) => ( {
456- limit : ( ) => [ ] ,
457- } ) ,
458- } ) ,
456+ where : ( ) => {
457+ // Return referral bonus for calculateTotalLegacyReferralBonus
458+ // This is a thenable that returns the referral bonus result
459+ return Promise . resolve ( [ { totalCredits : String ( legacyReferralBonus ) } ] )
460+ } ,
459461 } ) ,
460462 } ) ,
461463 } ,
@@ -491,15 +493,15 @@ describe('grant-credits', () => {
491493 }
492494 const legacyReferralBonus = 0 // No legacy referrals
493495
496+ // Mock db for calculateTotalLegacyReferralBonus (uses db directly, not tx)
494497 await mockModule ( '@codebuff/internal/db' , ( ) => ( {
495498 default : {
496499 select : ( ) => ( {
497500 from : ( ) => ( {
498- where : ( ) => ( {
499- orderBy : ( ) => ( {
500- limit : ( ) => [ ] ,
501- } ) ,
502- } ) ,
501+ where : ( ) => {
502+ // Return 0 referral bonus for calculateTotalLegacyReferralBonus
503+ return Promise . resolve ( [ { totalCredits : String ( legacyReferralBonus ) } ] )
504+ } ,
503505 } ) ,
504506 } ) ,
505507 } ,
You can’t perform that action at this time.
0 commit comments