import { describe, it, expect } from 'vitest';
import { LeagueScoringPresetViewModel } from './LeagueScoringPresetViewModel';

describe('LeagueScoringPresetViewModel', () => {
  it('exposes required fields from input', () => {
    const input = {
      id: 'preset-1',
      name: 'Standard scoring',
      sessionSummary: 'Sprint + Main',
      bonusSummary: 'Pole: +1',
      defaultTimings: {
        practiceMinutes: 10,
        qualifyingMinutes: 15,
        sprintRaceMinutes: 20,
        mainRaceMinutes: 40,
        sessionCount: 2,
      },
    };

    const vm = new LeagueScoringPresetViewModel(input);

    expect(vm.id).toBe('preset-1');
    expect(vm.name).toBe('Standard scoring');
    expect(vm.sessionSummary).toBe('Sprint + Main');
    expect(vm.bonusSummary).toBe('Pole: +1');
    expect(vm.defaultTimings).toEqual(input.defaultTimings);

    expect(typeof vm.id).toBe('string');
    expect(typeof vm.name).toBe('string');
    expect(typeof vm.sessionSummary).toBe('string');
    expect(typeof vm.bonusSummary).toBe('string');

    expect(typeof vm.defaultTimings.practiceMinutes).toBe('number');
    expect(typeof vm.defaultTimings.qualifyingMinutes).toBe('number');
    expect(typeof vm.defaultTimings.sprintRaceMinutes).toBe('number');
    expect(typeof vm.defaultTimings.mainRaceMinutes).toBe('number');
    expect(typeof vm.defaultTimings.sessionCount).toBe('number');
  });

  it('allows bonusSummary to be omitted', () => {
    const input = {
      id: 'preset-1',
      name: 'Standard scoring',
      sessionSummary: 'Sprint + Main',
      defaultTimings: {
        practiceMinutes: 10,
        qualifyingMinutes: 15,
        sprintRaceMinutes: 20,
        mainRaceMinutes: 40,
        sessionCount: 2,
      },
    };

    const vm = new LeagueScoringPresetViewModel(input);

    expect(vm.bonusSummary).toBeUndefined();
  });
});