import { describe, it, expect, beforeEach } from 'vitest';
import { GetAnalyticsMetricsPresenter } from './GetAnalyticsMetricsPresenter';
import type { GetAnalyticsMetricsOutput } from '@core/analytics/application/use-cases/GetAnalyticsMetricsUseCase';

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

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

  it('maps output to DTO correctly', () => {
    const output: GetAnalyticsMetricsOutput = {
      pageViews: 1000,
      uniqueVisitors: 500,
      averageSessionDuration: 300,
      bounceRate: 0.4,
    };

    presenter.present(output);

    const dto = presenter.getResponseModel();

    expect(dto).toEqual({
      pageViews: 1000,
      uniqueVisitors: 500,
      averageSessionDuration: 300,
      bounceRate: 0.4,
    });
    expect(presenter.responseModel).toEqual({
      pageViews: 1000,
      uniqueVisitors: 500,
      averageSessionDuration: 300,
      bounceRate: 0.4,
    });
  });

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

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