import { describe, expect, it } from 'vitest'

import { displayPostImportStatus } from '@/components/posts/import/postImportRowStatus'
import { buildPostImportRow } from '@/test/postImportFactories'

describe ('displayPostImportStatus', () => {
  it ('shows only ready, warning, and skipped states', () => {
    expect (displayPostImportStatus (buildPostImportRow ())).toBe ('ready')
    expect (displayPostImportStatus (buildPostImportRow ({
      status: 'warning',
      fieldWarnings: { title: ['warning'] } }))).toBe ('warning')
    expect (displayPostImportStatus (buildPostImportRow ({
      skipReason: 'existing',
      existingPostId: 2 }))).toBe ('skipped')
    expect (displayPostImportStatus (buildPostImportRow ({
      skipReason: 'manual' }))).toBe ('skipped')
  })

  it ('distinguishes validation, failure, and created states', () => {
    expect (displayPostImportStatus (buildPostImportRow ({
      status: 'error',
      validationErrors: { title: ['invalid'] } }))).toBe ('error')
    expect (displayPostImportStatus (buildPostImportRow ({
      importStatus: 'failed' }))).toBe ('failed')
    expect (displayPostImportStatus (buildPostImportRow ({
      importStatus: 'created',
      createdPostId: 3 }))).toBe ('created')
  })
})
