import { render, screen } from '@testing-library/react';
import { ThemeProvider } from '../../theme';
import type { PaymentTransactionStatus } from '@/services/payment/types';

// next-intl mocked to echo keys — each status must resolve its own pstatus_* label key.
jest.mock('next-intl', () => ({
  useTranslations: () => (key: string) => key,
}));

import PaymentStatusBadge from './PaymentStatusBadge';

function renderBadge(status: PaymentTransactionStatus) {
  return render(
    <ThemeProvider>
      <PaymentStatusBadge status={status} />
    </ThemeProvider>,
  );
}

// Every b10 wire status → its label key + the semantic chip kind it must map to.
const CASES: Array<{ status: PaymentTransactionStatus; kind: string }> = [
  { status: 'pending', kind: 'pending' },
  { status: 'succeeded', kind: 'verified' },
  { status: 'failed', kind: 'rejected' },
];

describe('<PaymentStatusBadge/> component', () => {
  it.each(CASES)('renders the $status status with its label key and chip kind', ({ status, kind }) => {
    const { container } = renderBadge(status);
    expect(screen.getByText(`pstatus_${status}`)).toBeInTheDocument();
    expect(container.querySelector(`[data-status="${kind}"]`)).toBeInTheDocument();
  });
});
