import { describe, expect, it } from 'vitest'
import { getSlaBadge, normalizeRejectReason } from '../approval'

describe('approval utils', () => {
  it('returns danger badge when overtime', () => {
    const now = new Date('2026-02-10T12:00:00Z')
    const requestedAt = '2026-02-08T00:00:00Z'
    const badge = getSlaBadge(requestedAt, now)

    expect(badge.level).toBe('danger')
    expect(badge.label).toContain('超时')
  })

  it('normalizes empty reject reason', () => {
    expect(normalizeRejectReason('')).toBe('批量拒绝')
    expect(normalizeRejectReason('  自定义原因  ')).toBe('自定义原因')
  })
})
