import { createBillingCatalog } from './billing-catalog.ts' import { PLAN_PRICE_KRW } from './core-contract.generated.ts' function assert(condition: unknown, message: string): asserts condition { if (!condition) throw new Error(message) } Deno.test('catalog exposes only configured Payple prices and never invents a fallback', () => { const catalog = createBillingCatalog({ payple: { pro: PLAN_PRICE_KRW.pro, pro_plus: PLAN_PRICE_KRW.pro_plus }, }) assert( catalog.plans.every((plan) => plan.prices.length === 1 && plan.prices[0].provider === 'payple'), 'each paid plan must expose exactly one Payple price', ) assert( catalog.plans[0].prices[0].unit_amount === PLAN_PRICE_KRW.pro && catalog.plans[1].prices[0].unit_amount === PLAN_PRICE_KRW.pro_plus, 'Payple prices must come from the core plan catalog', ) assert( catalog.plans.every((plan) => plan.prices[0].currency === 'KRW' && plan.prices[0].interval === 'month'), 'Payple prices are monthly KRW', ) const unavailable = createBillingCatalog({}) assert(unavailable.plans.every((plan) => plan.prices.length === 0), 'missing configuration must stay unavailable') }) Deno.test('catalog rejects non-positive or non-integer Payple amounts', () => { const catalog = createBillingCatalog({ payple: { pro: 0, pro_plus: 1.5 } }) assert(catalog.plans.every((plan) => plan.prices.length === 0), 'invalid amounts must fail closed') })