import { describe, it, expect, beforeEach } from 'vitest'; import { GetEntitySponsorshipPricingPresenter } from './GetEntitySponsorshipPricingPresenter'; import type { GetEntitySponsorshipPricingResult } from '@core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase'; describe('GetEntitySponsorshipPricingPresenter', () => { let presenter: GetEntitySponsorshipPricingPresenter; beforeEach(() => { presenter = new GetEntitySponsorshipPricingPresenter(); }); describe('reset', () => { it('should reset the result to null', () => { const mockResult: GetEntitySponsorshipPricingResult = { entityType: 'season', entityId: 'season-1', acceptingApplications: true, tiers: [] }; 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: GetEntitySponsorshipPricingResult = { entityType: 'season', entityId: 'season-1', acceptingApplications: true, tiers: [] }; 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: GetEntitySponsorshipPricingResult = { entityType: 'season', entityId: 'season-1', acceptingApplications: true, tiers: [] }; 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: GetEntitySponsorshipPricingResult = { entityType: 'season', entityId: 'season-1', acceptingApplications: true, tiers: [] }; presenter.present(mockResult); const expectedViewModel = { entityType: 'season', entityId: 'season-1', pricing: [] }; expect(presenter.viewModel).toEqual(expectedViewModel); }); }); });