import { mmddInRange, findMatchingSeasonId } from './season-date';

describe('season-date', () => {
  it('matches a year-wrapping Peak range (Nov–Mar)', () => {
    const seasons = [
      { id: 'peak', start_date: '11-01', end_date: '03-31', is_active: true },
      { id: 'hss', start_date: '04-01', end_date: '05-31', is_active: true },
    ];
    expect(findMatchingSeasonId(seasons, '2026-12-15')).toBe('peak');
    expect(findMatchingSeasonId(seasons, '2026-02-01')).toBe('peak');
    expect(findMatchingSeasonId(seasons, '2026-04-15')).toBe('hss');
  });

  it('uses durations[] when present', () => {
    const seasons = [
      {
        id: 'peak',
        start_date: '11-01',
        end_date: '03-31',
        durations: [
          { start: '11-01', end: '03-31' },
          { start: '07-01', end: '07-15' },
        ],
        is_active: true,
      },
    ];
    expect(findMatchingSeasonId(seasons, '2026-07-10')).toBe('peak');
    expect(findMatchingSeasonId(seasons, '2026-08-01')).toBeNull();
  });

  it('mmddInRange wraps across new year', () => {
    expect(mmddInRange('12-15', '11-01', '03-31')).toBe(true);
    expect(mmddInRange('06-01', '11-01', '03-31')).toBe(false);
  });
});
