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

import { extractPiffLegs } from '../piff';

describe('piff', () => {
  it('merges top-level and nested board legs without dropping board-only props', () => {
    const legs = extractPiffLegs({
      date: '2026-03-30',
      legs: [
        {
          name: 'Trae Young',
          team: 'ATL',
          stat: 'assists',
          line: 9.5,
          edge: 0.08,
          prob: 0.61,
          direction: 'over',
        },
      ],
      main_card: {
        legs: [
          {
            name: 'Trae Young',
            team: 'ATL',
            stat: 'assists',
            line: 9.5,
            edge: 0.08,
            prob: 0.61,
            direction: 'over',
          },
          {
            name: 'Jalen Johnson',
            team: 'ATL',
            stat: 'rebounds',
            line: 7.5,
            edge: 0.06,
            prob: 0.58,
            direction: 'over',
          },
        ],
      },
      watchlist: {
        legs: [
          {
            name: 'Derrick White',
            team: 'BOS',
            stat: 'threes',
            line: 2.5,
            edge: 0.05,
            prob: 0.56,
            direction: 'under',
          },
        ],
      },
    });

    expect(legs).toHaveLength(3);
    expect(legs.map((leg) => leg.name)).toEqual([
      'Trae Young',
      'Jalen Johnson',
      'Derrick White',
    ]);
  });
});
