import React from 'react';
import { describe, it, expect } from 'vitest';
import { render, screen } from '@testing-library/react';

import LeagueHeader from './LeagueHeader';

describe('LeagueHeader', () => {
  it('renders league name, description and sponsor', () => {
    render(
      <LeagueHeader
        leagueId="league-1"
        leagueName="Test League"
        description="A fun test league"
        ownerId="owner-1"
        ownerName="Owner Name"
        mainSponsor={{
          name: 'Test Sponsor',
          websiteUrl: 'https://example.com',
        }}
      />
    );

    expect(screen.getByText('Test League')).toBeInTheDocument();
    expect(screen.getByText('A fun test league')).toBeInTheDocument();
    expect(screen.getByText('by')).toBeInTheDocument();
    expect(screen.getByText('Test Sponsor')).toBeInTheDocument();
  });

  it('renders without description or sponsor', () => {
    render(
      <LeagueHeader
        leagueId="league-2"
        leagueName="League Without Details"
        ownerId="owner-2"
        ownerName="Owner 2"
      />
    );

    expect(screen.getByText('League Without Details')).toBeInTheDocument();
  });
});
