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

import { __espnMlbInternals } from '../espn-mlb';

describe('espn-mlb date normalization', () => {
  it('accepts ISO-like strings', () => {
    expect(__espnMlbInternals.toDateToken('2026-03-28T20:10:00.000Z')).toBe('20260328');
    expect(__espnMlbInternals.toDateToken('2026-03-28 16:10:00-04')).toBe('20260328');
  });

  it('accepts Date instances', () => {
    expect(__espnMlbInternals.toDateToken(new Date('2026-03-28T20:10:00.000Z'))).toBe('20260328');
  });

  it('returns null for junk input instead of throwing', () => {
    expect(__espnMlbInternals.toDateToken(null)).toBeNull();
    expect(__espnMlbInternals.toDateToken('')).toBeNull();
    expect(__espnMlbInternals.toDateToken({} as any)).toBeNull();
  });
});
