import { render, screen } from '@testing-library/react';

import { type Testimonial } from '@/Components/marketing/TestimonialCarousel';

import { TestimonialsSection } from './TestimonialsSection';

const makeTestimonial = (overrides: Partial<Testimonial> = {}): Testimonial => ({
  id: 1,
  name: 'Jane Doe',
  role: 'SEO Manager',
  company: 'Acme Corp',
  quote: 'This tool is fantastic.',
  avatar_url: null,
  rating: 5,
  source: 'direct',
  source_url: null,
  featured: false,
  ...overrides,
});

describe('TestimonialsSection', () => {
  it('renders nothing when testimonials list is empty', () => {
    const { container } = render(<TestimonialsSection testimonials={[]} />);
    expect(container.firstChild).toBeNull();
  });

  it('renders the section heading when testimonials are provided', () => {
    const testimonials: Testimonial[] = [makeTestimonial({ id: 1 })];
    render(<TestimonialsSection testimonials={testimonials} />);
    expect(screen.getByText('What SEO Professionals Say')).toBeInTheDocument();
  });

  it('shows static copy when isStatic is true', () => {
    const testimonials: Testimonial[] = [makeTestimonial({ id: 1 })];
    render(<TestimonialsSection testimonials={testimonials} isStatic />);
    expect(screen.getByText(/Trusted by SEO professionals and content teams/)).toBeInTheDocument();
  });

  it('shows live copy when isStatic is false', () => {
    const testimonials: Testimonial[] = [makeTestimonial({ id: 1 })];
    render(<TestimonialsSection testimonials={testimonials} isStatic={false} />);
    expect(screen.getByText(/Real feedback from SEO professionals/)).toBeInTheDocument();
  });
});
