import { describe, it, expect, beforeEach } from 'vitest';
import { GetSponsorshipPricingPresenter } from './GetSponsorshipPricingPresenter';
import type { GetSponsorshipPricingResult } from '@core/racing/application/use-cases/GetSponsorshipPricingUseCase';

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

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

  describe('reset', () => {
    it('should reset the result to null', () => {
      const mockResult: GetSponsorshipPricingResult = {
        entityType: 'season',
        entityId: 'season-1',
        pricing: []
      };
      presenter.present(mockResult);
      
      const expectedViewModel = {
        entityType: 'season',
        entityId: 'season-1',
        pricing: []
      };
      expect(presenter.viewModel).toEqual(expectedViewModel);

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

  describe('present', () => {
    it('should store the result', () => {
      const mockResult: GetSponsorshipPricingResult = {
        entityType: 'season',
        entityId: 'season-1',
        pricing: []
      };

      presenter.present(mockResult);

      const expectedViewModel = {
        entityType: 'season',
        entityId: 'season-1',
        pricing: []
      };
      expect(presenter.viewModel).toEqual(expectedViewModel);
    });
  });

  describe('getViewModel', () => {
    it('should return null when not presented', () => {
      expect(presenter.getViewModel()).toBeNull();
    });

    it('should return the result when presented', () => {
      const mockResult: GetSponsorshipPricingResult = {
        entityType: 'season',
        entityId: 'season-1',
        pricing: []
      };
      presenter.present(mockResult);

      const expectedViewModel = {
        entityType: 'season',
        entityId: 'season-1',
        pricing: []
      };
      expect(presenter.getViewModel()).toEqual(expectedViewModel);
    });
  });

  describe('viewModel', () => {
    it('should throw error when not presented', () => {
      expect(() => presenter.viewModel).toThrow('Presenter not presented');
    });

    it('should return the result when presented', () => {
      const mockResult: GetSponsorshipPricingResult = {
        entityType: 'season',
        entityId: 'season-1',
        pricing: []
      };
      presenter.present(mockResult);

      const expectedViewModel = {
        entityType: 'season',
        entityId: 'season-1',
        pricing: []
      };
      expect(presenter.viewModel).toEqual(expectedViewModel);
    });
  });
});