import { describe, it, expect } from 'vitest' import { isTerminal, isSuccess, statusTone, isCancellable, isRefundable, statusHelpKey, } from './status' import { PAYMENT_STATUSES } from '../types' describe('payment status presentation', () => { it('terminal states', () => { for (const s of ['succeeded', 'failed', 'cancelled', 'refunded', 'expired'] as const) expect(isTerminal(s)).toBe(true) for (const s of ['created', 'requires_customer_action', 'authorizing', 'processing', 'partially_refunded'] as const) expect(isTerminal(s)).toBe(false) }) it('processing is NOT success', () => { expect(isSuccess('processing')).toBe(false) expect(isSuccess('succeeded')).toBe(true) }) it('tones', () => { expect(statusTone('succeeded')).toBe('ok') expect(statusTone('failed')).toBe('bad') expect(statusTone('processing')).toBe('warn') }) it('cancellable states mirror the backend (created/req-action/authorizing only)', () => { for (const s of ['created', 'requires_customer_action', 'authorizing'] as const) expect(isCancellable(s)).toBe(true) for (const s of ['processing', 'succeeded', 'failed', 'cancelled', 'refunded', 'expired', 'partially_refunded'] as const) expect(isCancellable(s)).toBe(false) }) it('refundable states are succeeded / partially_refunded', () => { expect(isRefundable('succeeded')).toBe(true) expect(isRefundable('partially_refunded')).toBe(true) expect(isRefundable('processing')).toBe(false) expect(isRefundable('failed')).toBe(false) }) it('every status has a help key', () => { for (const s of PAYMENT_STATUSES) expect(statusHelpKey(s)).toBe(`statusHelp.${s}`) }) })