import { render, screen, fireEvent } from '@testing-library/react';
import { ThemeProvider } from '../../theme';

jest.mock('next-intl', () => ({
  useTranslations: () => (key: string) => key,
}));

import AdminErrorState from './AdminErrorState';

describe('<AdminErrorState/>', () => {
  const wrap = (ui: React.ReactNode) => render(<ThemeProvider>{ui}</ThemeProvider>);

  it('renders the message and calls onRetry on click', () => {
    const onRetry = jest.fn();
    wrap(<AdminErrorState message="Failed" retryLabel="Retry" onRetry={onRetry} />);
    expect(screen.getByText('Failed')).toBeInTheDocument();
    fireEvent.click(screen.getByRole('button', { name: /Retry/ }));
    expect(onRetry).toHaveBeenCalledTimes(1);
  });
});
