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

describe('MarketingTemplate', () => {
  it('renders hero section when provided', () => {
    const heroSection = <HeroBlock title="Hero Title" subtitle="Hero Subtitle" />;
    render(<MarketingTemplate hero={heroSection} sections={[]} />);
    expect(screen.getByText('Hero Title')).toBeInTheDocument();
    expect(screen.getByText('Hero Subtitle')).toBeInTheDocument();
  });

  it('renders sections when provided', () => {
    const sections = [
      <div key="1">Section 1</div>,
      <div key="2">Section 2</div>,
    ];
    render(<MarketingTemplate hero={null} sections={sections} />);
    expect(screen.getByText('Section 1')).toBeInTheDocument();
    expect(screen.getByText('Section 2')).toBeInTheDocument();
  });

  it('renders sidebar when provided', () => {
    const sidebar = <div>Sidebar Content</div>;
    render(<MarketingTemplate hero={null} sections={[]} sidebar={sidebar} />);
    expect(screen.getByText('Sidebar Content')).toBeInTheDocument();
  });

  it('handles empty sections', () => {
    render(<MarketingTemplate hero={null} sections={[]} />);
    expect(screen.queryByText('Section')).not.toBeInTheDocument();
  });

  it('renders all sections together', () => {
    const heroSection = <HeroBlock title="Hero" />;
    const sections = [<div key="1">Content</div>];
    const sidebar = <div>Sidebar</div>;
    
    render(
      <MarketingTemplate
        hero={heroSection}
        sections={sections}
        sidebar={sidebar}
      />
    );
    
    expect(screen.getByText('Hero')).toBeInTheDocument();
    expect(screen.getByText('Content')).toBeInTheDocument();
    expect(screen.getByText('Sidebar')).toBeInTheDocument();
  });
});

