import { describe, it, expect, beforeEach } from 'vitest';
import { DriverStatsPresenter } from './DriverStatsPresenter';
import type { TotalDriversResultDTO } from '../../../../../core/racing/application/presenters/ITotalDriversPresenter';

describe('DriverStatsPresenter', () => {
  let presenter: DriverStatsPresenter;

  beforeEach(() => {
    presenter = new DriverStatsPresenter();
  });

  describe('present', () => {
    it('should map core DTO to API view model correctly', () => {
      const dto: TotalDriversResultDTO = {
        totalDrivers: 42,
      };

      presenter.present(dto);

      const result = presenter.viewModel;

      expect(result).toEqual({
        totalDrivers: 42,
      });
    });
  });

  describe('reset', () => {
    it('should reset the result', () => {
      const dto: TotalDriversResultDTO = {
        totalDrivers: 10,
      };

      presenter.present(dto);
      expect(presenter.viewModel).toBeDefined();

      presenter.reset();
      expect(() => presenter.viewModel).toThrow('Presenter not presented');
    });
  });
});