import { describe, it, expect } from 'vitest';
import { presentRaceResult } from './RaceResultsPresenter';
import { RaceResultViewModel } from '../view-models';
import type { RaceResultRowDto } from '../dtos';

describe('RaceResultsPresenter', () => {
  describe('presentRaceResult', () => {
    it('should transform RaceResultRowDto into RaceResultViewModel', () => {
      const dto: RaceResultRowDto = {
        id: '1',
        raceId: 'race-1',
        driverId: 'driver-1',
        position: 1,
        fastestLap: 85.5,
        incidents: 0,
        startPosition: 2,
      };

      const result = presentRaceResult(dto);

      expect(result).toBeInstanceOf(RaceResultViewModel);
      expect(result.id).toBe('1');
      expect(result.raceId).toBe('race-1');
      expect(result.driverId).toBe('driver-1');
      expect(result.position).toBe(1);
      expect(result.fastestLap).toBe(85.5);
      expect(result.incidents).toBe(0);
      expect(result.startPosition).toBe(2);
    });

    it('should handle zero values correctly', () => {
      const dto: RaceResultRowDto = {
        id: '2',
        raceId: 'race-2',
        driverId: 'driver-2',
        position: 5,
        fastestLap: 0,
        incidents: 3,
        startPosition: 5,
      };

      const result = presentRaceResult(dto);

      expect(result).toBeInstanceOf(RaceResultViewModel);
      expect(result.id).toBe('2');
      expect(result.position).toBe(5);
      expect(result.fastestLap).toBe(0);
      expect(result.incidents).toBe(3);
      expect(result.startPosition).toBe(5);
    });
  });
});