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

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

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

  describe('present', () => {
    it('should map parameters to view model for registered driver', () => {
      presenter.present(true, 'race-123', 'driver-456');

      const result = presenter.viewModel;

      expect(result).toEqual({
        isRegistered: true,
        raceId: 'race-123',
        driverId: 'driver-456',
      });
    });

    it('should map parameters to view model for unregistered driver', () => {
      presenter.present(false, 'race-789', 'driver-101');

      const result = presenter.viewModel;

      expect(result).toEqual({
        isRegistered: false,
        raceId: 'race-789',
        driverId: 'driver-101',
      });
    });
  });

  describe('reset', () => {
    it('should reset the result', () => {
      presenter.present(true, 'race-123', 'driver-456');
      expect(presenter.viewModel).toBeDefined();

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