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

describe('<NotificationBellView/> component', () => {
  it('renders the unread count + aria label and fires onClick', () => {
    const onClick = jest.fn();
    render(
      <ThemeProvider>
        <NotificationBellView count={3} label="۳ اعلان خوانده‌نشده" onClick={onClick} />
      </ThemeProvider>,
    );
    const bell = screen.getByTestId('notification-bell');
    expect(bell).toHaveAttribute('aria-label', '۳ اعلان خوانده‌نشده');
    expect(screen.getByText('3')).toBeInTheDocument();
    fireEvent.click(bell);
    expect(onClick).toHaveBeenCalledTimes(1);
  });

  it('hides the badge when there are no unread notifications', () => {
    render(
      <ThemeProvider>
        <NotificationBellView count={0} label="اعلان‌ها" onClick={() => {}} />
      </ThemeProvider>,
    );
    expect(screen.queryByText('0')).not.toBeInTheDocument();
  });
});
