import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { ListingStatusBadge } from '../listing-status-badge';

describe('ListingStatusBadge', () => {
  it('renders ACTIVE status with correct label', () => {
    render(<ListingStatusBadge status="ACTIVE" />);
    expect(screen.getByText('Đang bán')).toBeInTheDocument();
  });

  it('renders DRAFT status with correct label', () => {
    render(<ListingStatusBadge status="DRAFT" />);
    expect(screen.getByText('Nháp')).toBeInTheDocument();
  });

  it('renders PENDING_REVIEW status with correct label', () => {
    render(<ListingStatusBadge status="PENDING_REVIEW" />);
    expect(screen.getByText('Chờ duyệt')).toBeInTheDocument();
  });

  it('renders SOLD status with correct label', () => {
    render(<ListingStatusBadge status="SOLD" />);
    expect(screen.getByText('Đã bán')).toBeInTheDocument();
  });

  it('renders RENTED status with correct label', () => {
    render(<ListingStatusBadge status="RENTED" />);
    expect(screen.getByText('Đã cho thuê')).toBeInTheDocument();
  });

  it('renders EXPIRED status with correct label', () => {
    render(<ListingStatusBadge status="EXPIRED" />);
    expect(screen.getByText('Hết hạn')).toBeInTheDocument();
  });

  it('renders REJECTED status with correct label', () => {
    render(<ListingStatusBadge status="REJECTED" />);
    expect(screen.getByText('Bị từ chối')).toBeInTheDocument();
  });

  it('renders RESERVED status with correct label', () => {
    render(<ListingStatusBadge status="RESERVED" />);
    expect(screen.getByText('Đã đặt cọc')).toBeInTheDocument();
  });

  it('falls back to raw status value for unknown status', () => {
    // @ts-expect-error testing unknown status
    render(<ListingStatusBadge status="UNKNOWN_STATUS" />);
    expect(screen.getByText('UNKNOWN_STATUS')).toBeInTheDocument();
  });
});
