LCOV - code coverage report
Current view: top level - src/platform/billing/subscription/utils - planCreditGrant.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 80.0 % 10 8
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import {
       2              :   getTierCredits,
       3              :   toTierKey
       4              : } from '@/platform/billing/subscription/constants/tierPricing'
       5              : import type {
       6              :   SubscriptionDuration,
       7              :   SubscriptionTier
       8              : } from '@comfyorg/billing-core'
       9              : 
      10              : export interface PlanCreditGrant {
      11              :   credits: number
      12              :   cycle: 'monthly' | 'yearly'
      13              : }
      14              : 
      15           10 : export function getPlanCreditGrant({
      16              :   tier,
      17              :   duration,
      18              :   teamMonthlyCredits
      19              : }: {
      20              :   tier: SubscriptionTier | null | undefined
      21              :   duration: SubscriptionDuration | null | undefined
      22              :   teamMonthlyCredits?: number | null
      23              : }): PlanCreditGrant | null {
      24           10 :   if (!tier) return null
      25            6 :   const tierKey = toTierKey(tier)
      26           10 :   const monthlyCredits =
      27              :     teamMonthlyCredits ?? (tierKey ? getTierCredits(tierKey) : null)
      28           10 :   if (!monthlyCredits) return null
      29            6 :   if (duration === 'ANNUAL')
      30            0 :     return { credits: monthlyCredits * 12, cycle: 'yearly' }
      31           10 :   if (duration === 'MONTHLY' || tierKey === 'founder')
      32            6 :     return { credits: monthlyCredits, cycle: 'monthly' }
      33            0 :   return null
      34              : }
        

Generated by: LCOV version 2.0-1