Files
baya-monorepo/client/src/components/common/ErrorState/ErrorState.test.tsx
T
2026-07-17 17:10:39 +03:30

21 lines
861 B
TypeScript

import { render, screen, fireEvent } from '@testing-library/react';
import { ThemeProvider } from '../../../theme';
import ErrorState from './ErrorState';
describe('<ErrorState/>', () => {
const wrap = (ui: React.ReactNode) => render(<ThemeProvider>{ui}</ThemeProvider>);
it('renders the message and calls onRetry on click', () => {
const onRetry = jest.fn();
wrap(<ErrorState message="Couldn't load" retryLabel="Retry" onRetry={onRetry} />);
expect(screen.getByText("Couldn't load")).toBeInTheDocument();
fireEvent.click(screen.getByRole('button'));
expect(onRetry).toHaveBeenCalledTimes(1);
});
it('renders the caller-supplied retry label', () => {
wrap(<ErrorState message="Failed" retryLabel="Try again" onRetry={jest.fn()} />);
expect(screen.getByRole('button', { name: 'Try again' })).toBeInTheDocument();
});
});