import type { GetDashboardDataOutput } from '@core/analytics/application/use-cases/GetDashboardDataUseCase';
import { beforeEach, describe, expect, it } from 'vitest';
import { GetDashboardDataPresenter } from './GetDashboardDataPresenter';

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

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

  it('maps output to DTO correctly', () => {
    const output: GetDashboardDataOutput = {
      totalUsers: 100,
      activeUsers: 50,
      totalRaces: 20,
      totalLeagues: 5,
    };

    presenter.transform(output);

    expect(presenter.getResponseModel()).toEqual({
      totalUsers: 100,
      activeUsers: 50,
      totalRaces: 20,
      totalLeagues: 5,
    });
    expect(presenter.responseModel).toEqual({
      totalUsers: 100,
      activeUsers: 50,
      totalRaces: 20,
      totalLeagues: 5,
    });
  });

  it('getResponseModel throws if not transformed', () => {
    expect(() => presenter.getResponseModel()).toThrow('Presenter not transformed');
  });

  it('responseModel throws if not transformed', () => {
    expect(() => presenter.responseModel).toThrow('Presenter not transformed');
  });
});
