import { describe, expect, it } from 'vitest'
import { customerRouteStatus } from '@/lib/domain/purchases'

const s = (purchaseStatus: string, fulfillmentStatus: string, routeVersion?: number) =>
  customerRouteStatus({ purchaseStatus: purchaseStatus as never, fulfillmentStatus: fulfillmentStatus as never, routeVersion })

describe('what the customer sees for a route item', () => {
  it('says plainly when they were never charged', () => {
    expect(s('payment_failed', 'awaiting_payment')).toBe('Purchase failed — you were not charged')
    expect(s('expired', 'awaiting_payment')).toBe('Purchase failed — you were not charged')
  })
  it('shows Processing from payment until Synchron delivers', () => {
    for (const f of ['ready_for_processing', 'submitted_to_synchron', 'processing', 'needs_review']) expect(s('paid', f)).toBe('Processing')
  })
  it('shows Ready, and Updated once a route was corrected', () => {
    expect(s('paid', 'completed')).toBe('Ready')
    expect(s('paid', 'completed', 2)).toBe('Ready · Updated')
  })
  it('shows Canceled and Refunded', () => {
    expect(s('paid', 'cancelled')).toBe('Canceled')
    expect(s('refunded', 'completed')).toBe('Refunded')
    expect(s('partially_refunded', 'failed')).toBe('Refunded')
  })
  it('shows Awaiting payment during checkout', () => {
    expect(s('pending_payment', 'awaiting_payment')).toBe('Awaiting payment')
  })
})
