import { describe, expect, it } from 'vitest';
import { describeForecastAsset, getMlbPlayerRole, summarizeForecastCountRows } from '../forecast-asset-taxonomy';

describe('forecast-asset-taxonomy', () => {
  it('classifies explicit MLB market families', () => {
    expect(describeForecastAsset('GAME_TOTAL')).toMatchObject({
      marketFamily: 'game_total',
      marketOrigin: 'source_backed',
    });
    expect(describeForecastAsset('MLB_RUN_LINE')).toMatchObject({
      marketFamily: 'run_line',
      marketOrigin: 'source_backed',
    });
    expect(describeForecastAsset('MLB_F5_SIDE')).toMatchObject({
      marketFamily: 'f5_side',
      marketOrigin: 'modeled',
    });
    expect(describeForecastAsset('MLB_F5_TOTAL')).toMatchObject({
      marketFamily: 'f5_total',
      marketOrigin: 'modeled',
    });
  });

  it('distinguishes batter and pitcher props', () => {
    expect(getMlbPlayerRole('batting_hits')).toBe('batter');
    expect(getMlbPlayerRole('pitching_strikeouts')).toBe('pitcher');
    expect(describeForecastAsset('PLAYER_PROP', { stat_type: 'batting_homeRuns' }).marketFamily).toBe('batter_props');
    expect(describeForecastAsset('PLAYER_PROP', { stat_type: 'pitching_outs' }).marketFamily).toBe('pitcher_props');
  });

  it('summarizes counts by type and family', () => {
    expect(summarizeForecastCountRows([
      { forecast_type: 'GAME_MARKETS', count: 2 },
      { forecast_type: 'GAME_TOTAL', count: 2 },
      { forecast_type: 'MLB_RUN_LINE', count: 2 },
      { forecast_type: 'PLAYER_PROP', count: 6 },
    ])).toEqual({
      byType: {
        GAME_MARKETS: 2,
        GAME_TOTAL: 2,
        MLB_RUN_LINE: 2,
        PLAYER_PROP: 6,
      },
      byFamily: {
        game_bundle: 2,
        game_total: 2,
        run_line: 2,
        player_props: 6,
      },
      total: 12,
    });
  });
});

