Commit a2d40d2
committed
feat: add DI support and tests for remaining billing functions
Auto-topup functions:
- validateAutoTopupStatus: DI for db and stripeServer
- checkAndTriggerAutoTopup: DI for db, stripe, calculateUsageAndBalance, etc.
- checkAndTriggerOrgAutoTopup: DI for db, stripe, org billing functions
Stripe metering:
- reportPurchasedCreditsToStripe: DI for db, stripe, shouldAttemptStripeMetering
Grant credits helpers:
- getPreviousFreeGrantAmount: DI for db
- calculateTotalReferralBonus: DI for db
- processAndGrantCredit: DI for grantCreditFn and logSyncFailure
New test files:
- auto-topup.test.ts: 19 tests for auto-topup DI
- stripe-metering.test.ts: 12 tests for stripe metering DI
- Updated grant-credits.test.ts with helper function tests
Type improvements:
- Added BillingOrganization type to contracts/billing.ts
- Added org query to BillingDbConnection interface
- Added org support to mock-db.ts1 parent b02392f commit a2d40d2
File tree
8 files changed
+1589
-53
lines changed- common/src
- testing
- types/contracts
- packages/billing/src
- __tests__
8 files changed
+1589
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
425 | 426 | | |
426 | 427 | | |
427 | 428 | | |
| 429 | + | |
428 | 430 | | |
429 | 431 | | |
430 | 432 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
46 | 59 | | |
47 | 60 | | |
48 | 61 | | |
| |||
208 | 221 | | |
209 | 222 | | |
210 | 223 | | |
| 224 | + | |
| 225 | + | |
211 | 226 | | |
212 | 227 | | |
213 | 228 | | |
| |||
0 commit comments