Files
Momento/memento-note/tests/unit/billing-price-map.test.ts
Antigravity bd495be965
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 12s
feat: design system overhaul — sidebar, AI chats, settings, brainstorm, color cleanup
- Sidebar: dynamic brand-accent colors, brainstorm section restyled
- AI chat general: popup panel with expand/collapse, hides when contextual AI open
- AI chat contextual: tabs reordered (Actions first), X close button, height fix
- Settings: all tabs restyled, 6 new color presets (sage, terracotta, iron, etc.)
- Global color cleanup: emerald/orange hardcoded → brand-accent dynamic
- Brainstorm page: orange → brand-accent throughout
- PageEntry animation component added to key pages
- Floating AI button: bg-brand-accent instead of hardcoded black
- i18n: all 15 locales updated with new AI/billing keys
- Billing: freemium quota tracking, BYOK, stripe subscription scaffolding
- Admin: integrated into new design
- AGENTS.md + CLAUDE.md project rules added
2026-05-16 12:59:30 +00:00

74 lines
2.4 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { resolvePriceId, priceIdToTier } from '@/lib/billing/stripe-prices';
describe('billing-price-map', () => {
const originalEnv = process.env;
beforeEach(() => {
process.env = {
...originalEnv,
STRIPE_PRICE_PRO_MONTHLY: 'price_pro_monthly_test',
STRIPE_PRICE_PRO_ANNUAL: 'price_pro_annual_test',
STRIPE_PRICE_BUSINESS_MONTHLY: 'price_business_monthly_test',
STRIPE_PRICE_BUSINESS_ANNUAL: 'price_business_annual_test',
};
});
afterEach(() => {
process.env = originalEnv;
});
describe('resolvePriceId', () => {
it('returns PRO monthly price ID', () => {
expect(resolvePriceId('PRO', 'month')).toBe('price_pro_monthly_test');
});
it('returns PRO annual price ID', () => {
expect(resolvePriceId('PRO', 'year')).toBe('price_pro_annual_test');
});
it('returns BUSINESS monthly price ID', () => {
expect(resolvePriceId('BUSINESS', 'month')).toBe('price_business_monthly_test');
});
it('returns BUSINESS annual price ID', () => {
expect(resolvePriceId('BUSINESS', 'year')).toBe('price_business_annual_test');
});
it('throws if env variable is not set', () => {
delete process.env.STRIPE_PRICE_PRO_MONTHLY;
expect(() => resolvePriceId('PRO', 'month')).toThrow();
});
});
describe('priceIdToTier', () => {
it('resolves PRO monthly price ID to PRO tier', () => {
expect(priceIdToTier('price_pro_monthly_test')).toBe('PRO');
});
it('resolves PRO annual price ID to PRO tier', () => {
expect(priceIdToTier('price_pro_annual_test')).toBe('PRO');
});
it('resolves BUSINESS monthly price ID to BUSINESS tier', () => {
expect(priceIdToTier('price_business_monthly_test')).toBe('BUSINESS');
});
it('resolves BUSINESS annual price ID to BUSINESS tier', () => {
expect(priceIdToTier('price_business_annual_test')).toBe('BUSINESS');
});
it('returns null for unknown price ID', () => {
expect(priceIdToTier('price_unknown_xyz')).toBeNull();
});
it('returns null when env variables are not set', () => {
delete process.env.STRIPE_PRICE_PRO_MONTHLY;
delete process.env.STRIPE_PRICE_PRO_ANNUAL;
delete process.env.STRIPE_PRICE_BUSINESS_MONTHLY;
delete process.env.STRIPE_PRICE_BUSINESS_ANNUAL;
expect(priceIdToTier('price_pro_monthly_test')).toBeNull();
});
});
});