/**
 * Tests for HeroBlock component
 */
import { render, screen, fireEvent } from '@testing-library/react';
import { HeroBlock } from '../HeroBlock';

describe('HeroBlock', () => {
  it('renders title correctly', () => {
    render(<HeroBlock title="Test Hero Title" />);
    expect(screen.getByText('Test Hero Title')).toBeInTheDocument();
  });

  it('renders subtitle when provided', () => {
    render(<HeroBlock title="Title" subtitle="Subtitle text" />);
    expect(screen.getByText('Subtitle text')).toBeInTheDocument();
  });

  it('renders eyebrow when provided', () => {
    render(<HeroBlock title="Title" eyebrow="Eyebrow text" />);
    expect(screen.getByText('Eyebrow text')).toBeInTheDocument();
  });

  it('renders CTA button when ctaLabel is provided', () => {
    render(<HeroBlock title="Title" ctaLabel="Click Me" />);
    expect(screen.getByText('Click Me')).toBeInTheDocument();
  });

  it('calls onCtaClick when CTA button is clicked', () => {
    const handleClick = jest.fn();
    render(<HeroBlock title="Title" ctaLabel="Click Me" onCtaClick={handleClick} />);
    
    const button = screen.getByText('Click Me');
    fireEvent.click(button);
    
    expect(handleClick).toHaveBeenCalledTimes(1);
  });

  it('renders supporting content when provided', () => {
    render(
      <HeroBlock
        title="Title"
        supportingContent={<div>Supporting content</div>}
      />
    );
    expect(screen.getByText('Supporting content')).toBeInTheDocument();
  });

  it('does not render CTA button when ctaLabel is not provided', () => {
    render(<HeroBlock title="Title" />);
    expect(screen.queryByRole('button')).not.toBeInTheDocument();
  });
});

