PartnerIcon.test.ts50 lines · main
| 1 | import { describe, expect, it } from 'vitest' |
| 2 | |
| 3 | import PartnerIcon, { getDefaultPartnerTooltipText, getPartnerTooltipText } from './PartnerIcon' |
| 4 | import { MANAGED_BY } from '@/lib/constants/infrastructure' |
| 5 | import { render } from '@/tests/helpers' |
| 6 | import type { Organization } from '@/types' |
| 7 | |
| 8 | describe('PartnerIcon tooltip copy', () => { |
| 9 | it('returns provider-specific default tooltip copy for AWS, Vercel, and Stripe', () => { |
| 10 | expect(getDefaultPartnerTooltipText(MANAGED_BY.VERCEL_MARKETPLACE)).toBe( |
| 11 | 'Managed via Vercel Marketplace' |
| 12 | ) |
| 13 | expect(getDefaultPartnerTooltipText(MANAGED_BY.AWS_MARKETPLACE)).toBe( |
| 14 | 'Billed via AWS Marketplace' |
| 15 | ) |
| 16 | expect(getDefaultPartnerTooltipText(MANAGED_BY.STRIPE_PROJECTS)).toBe('Connected to Stripe') |
| 17 | }) |
| 18 | |
| 19 | it('uses custom tooltip text when provided', () => { |
| 20 | expect( |
| 21 | getPartnerTooltipText({ |
| 22 | managedBy: MANAGED_BY.VERCEL_MARKETPLACE, |
| 23 | tooltipText: 'Managed by Vercel Marketplace.', |
| 24 | }) |
| 25 | ).toBe('Managed by Vercel Marketplace.') |
| 26 | }) |
| 27 | |
| 28 | it('falls back to default tooltip text when custom tooltip is not provided', () => { |
| 29 | expect( |
| 30 | getPartnerTooltipText({ |
| 31 | managedBy: MANAGED_BY.AWS_MARKETPLACE, |
| 32 | }) |
| 33 | ).toBe('Billed via AWS Marketplace') |
| 34 | }) |
| 35 | |
| 36 | it('renders an icon element for Stripe organizations', () => { |
| 37 | const organization = { |
| 38 | managed_by: MANAGED_BY.STRIPE_PROJECTS, |
| 39 | } as Pick<Organization, 'managed_by'> |
| 40 | |
| 41 | const { container } = render( |
| 42 | PartnerIcon({ |
| 43 | organization, |
| 44 | showTooltip: false, |
| 45 | }) |
| 46 | ) |
| 47 | |
| 48 | expect(container.querySelector('svg')).toBeTruthy() |
| 49 | }) |
| 50 | }) |