/* eslint-env jest */ import type { ICatalogPlan, IPlansCatalog, } from '../../service/plans/plans.interface'; import { freePlanSummary, PlanPeriod, PlanType, plansFromCatalog, } from '../plan'; import { pricingModel } from '../pricingModel'; /** * A catalog plan with only what these copy checks read. * * @param {Partial} plan - The fields that differ. * @return {ICatalogPlan} The plan. */ const catalogPlan = (plan: Partial): ICatalogPlan => ({ code: PlanType.FREE, name: 'Free', blurb: '', summary: '', order: 0, credits: 600, trial_days: 0, prices: {}, highlights: [], limits: {}, intensity: { agents: 0, audit: 0 }, ...plan, }); const PRICE = { lookup_key: 'monthly', price_id: 'price_1', amount: 39, monthly_equivalent: 39, }; const CATALOG: IPlansCatalog = { plans: [ catalogPlan({}), catalogPlan({ code: PlanType.STARTER, name: 'Starter', order: 1, credits: 1000, unit: { name: 'agent', min: 1, max: 6, credits: 1000 }, prices: { [PlanPeriod.MONTHLY]: PRICE }, }), catalogPlan({ code: PlanType.FAST_GROWING, name: 'Fast Growing', order: 2, credits: 10000, prices: { [PlanPeriod.MONTHLY]: PRICE }, }), ], agents: [], limit_rows: [], fixed_limit_rows: [], platform_rows: ['support'], limit_labels: { support: 'Support' }, launch_discount: { months: 0, monthly: {}, list_monthly: {} }, }; describe('Free credits copy', () => { it('says Free credits are granted once, not monthly', () => { expect(freePlanSummary(plansFromCatalog(CATALOG))).toBe( '600 credits, granted once, free. Upgrade any time for monthly credits and more features.' ); }); it('keeps the upgrade line when the catalog has no Free plan', () => { expect(freePlanSummary([])).toBe( 'Upgrade any time for monthly credits and more features.' ); }); it('shows Free as once and paid plans as a month in the compare table', () => { const rows = pricingModel(CATALOG).compareGroups[0].rows; const credits = rows.find(row => row.feature === 'AI credits'); expect(credits?.cells).toEqual([ '600 once', '1,000 per agent a month', '10,000 a month', ]); expect(rows.some(row => row.feature === 'AI credits a month')).toBe(false); }); });