import { describe, it, expect } from 'vitest';
import { RaceStatsViewModel } from './RaceStatsViewModel';
import type { RaceStatsDTO } from '../types/generated/RaceStatsDTO';

const createDto = (overrides: Partial<RaceStatsDTO> = {}): RaceStatsDTO => ({
  totalRaces: 1234,
  ...overrides,
});

describe('RaceStatsViewModel', () => {
  it('maps totalRaces from DTO', () => {
    const dto = createDto({ totalRaces: 42 });

    const viewModel = new RaceStatsViewModel(dto);

    expect(viewModel.totalRaces).toBe(42);
  });

  it('formats totalRaces with locale separators', () => {
    const dto = createDto({ totalRaces: 12345 });

    const viewModel = new RaceStatsViewModel(dto);

    const formatted = viewModel.formattedTotalRaces;

    expect(formatted).toBe((12345).toLocaleString());
  });
});
