import { describe, expect, it } from 'vitest';

import {
  isAllowedAmericanContent,
  isAllowedAmericanTrend,
  isAmericanSocialLeague,
  isAmericanSocialSport,
} from '../sport-policy';

describe('social-engine sport policy', () => {
  it('allows only approved American leagues and sports', () => {
    expect(isAmericanSocialLeague('nba')).toBe(true);
    expect(isAmericanSocialLeague('ncaaf')).toBe(true);
    expect(isAmericanSocialLeague('soccer')).toBe(false);

    expect(isAmericanSocialSport('basketball')).toBe(true);
    expect(isAmericanSocialSport('nba')).toBe(true);
    expect(isAmericanSocialSport('football')).toBe(true);
    expect(isAmericanSocialSport('mma')).toBe(false);
  });

  it('rejects non-American trends and allows recap trends built from American leagues', () => {
    expect(isAllowedAmericanTrend({
      trend_type: 'curated_news',
      sport: 'soccer',
      league: null,
      data: {},
    })).toBe(false);

    expect(isAllowedAmericanTrend({
      trend_type: 'curated_news',
      sport: 'basketball',
      league: null,
      data: {},
    })).toBe(true);

    expect(isAllowedAmericanTrend({
      trend_type: 'recap',
      sport: null,
      league: null,
      data: {
        games: [
          { league: 'nba' },
          { league: 'mlb' },
        ],
      },
    })).toBe(true);

    expect(isAllowedAmericanTrend({
      trend_type: 'recap',
      sport: null,
      league: null,
      data: {
        games: [
          { league: 'nba' },
          { league: 'epl' },
        ],
      },
    })).toBe(false);
  });

  it('blocks non-American approved content before distribution', () => {
    expect(isAllowedAmericanContent({
      content_type: 'curated_news',
      sport: 'soccer',
      league: null,
      source_data: {},
    })).toBe(false);

    expect(isAllowedAmericanContent({
      content_type: 'forecast_pick',
      sport: 'basketball',
      league: 'nba',
      source_data: {},
    })).toBe(true);
  });
});
