process.env.STRIPE_SECRET_KEY = 'sk_test_dummy'; jest.mock('../../src/utils/supabase', () => ({ getSupabaseServiceClient: () => ({ from: jest.fn() }), })); const { isFounderCodeValid, getPriceId } = require('../../src/services/stripeService'); describe('stripeService', () => { describe('isFounderCodeValid', () => { test('valid founder code returns true', () => { expect(isFounderCodeValid('FOUNDER2026')).toBe(true); expect(isFounderCodeValid('BETONBLK')).toBe(true); }); test('case insensitive', () => { expect(isFounderCodeValid('founder2026')).toBe(true); }); test('invalid code returns false', () => { expect(isFounderCodeValid('INVALID')).toBe(false); }); test('null/empty returns false', () => { expect(isFounderCodeValid(null)).toBe(false); expect(isFounderCodeValid('')).toBe(false); }); }); describe('getPriceId', () => { test('analyst without founder code returns standard price', () => { const id = getPriceId('analyst', null); expect(id).toContain('analyst'); expect(id).not.toContain('founder'); }); test('analyst with valid founder code returns founder price', () => { const id = getPriceId('analyst', 'FOUNDER2026'); expect(id).toContain('founder'); }); test('desk without founder code returns standard price', () => { const id = getPriceId('desk', null); expect(id).toContain('desk'); expect(id).not.toContain('founder'); }); test('desk with valid founder code returns founder price', () => { const id = getPriceId('desk', 'BETONBLK'); expect(id).toContain('founder'); }); test('invalid tier throws', () => { expect(() => getPriceId('gold', null)).toThrow('Invalid tier'); }); }); });