import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import ArticleCard from '@/components/article/ArticleCard'
import type { Article } from '@/lib/types'

const mockArticle: Article = {
  id: '1',
  title: 'Frieren Season 2 Officially Announced',
  slug: 'frieren-season-2-announced',
  status: 'published',
  content: null,
  excerpt: 'The beloved series returns.',
  featured_image: null,
  published_at: '2026-05-28T00:00:00Z',
  is_featured: false,
  seo_title: null,
  seo_description: null,
  category: { id: '1', name: 'Anime', slug: 'anime', description: null },
  tags: [],
}

describe('ArticleCard', () => {
  it('renders the article title', () => {
    render(<ArticleCard article={mockArticle} />)
    expect(screen.getByText('Frieren Season 2 Officially Announced')).toBeInTheDocument()
  })

  it('renders the category name', () => {
    render(<ArticleCard article={mockArticle} />)
    expect(screen.getByText('Anime')).toBeInTheDocument()
  })

  it('links to the correct article URL', () => {
    render(<ArticleCard article={mockArticle} />)
    const link = screen.getByRole('link')
    expect(link).toHaveAttribute('href', '/anime/frieren-season-2-announced')
  })

  it('renders the Read -> CTA', () => {
    render(<ArticleCard article={mockArticle} />)
    expect(screen.getByText('Read →')).toBeInTheDocument()
  })
})
