refactor api modules

This commit is contained in:
2025-12-22 19:17:33 +01:00
parent c90b2166c1
commit 1333f5e907
100 changed files with 2226 additions and 1936 deletions

View File

@@ -1,5 +1,6 @@
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;
@@ -10,9 +11,20 @@ describe('GetEntitySponsorshipPricingPresenter', () => {
describe('reset', () => {
it('should reset the result to null', () => {
const mockResult = { entityType: 'season', entityId: 'season-1', pricing: [] };
const mockResult: GetEntitySponsorshipPricingResult = {
entityType: 'season',
entityId: 'season-1',
acceptingApplications: true,
tiers: []
};
presenter.present(mockResult);
expect(presenter.viewModel).toEqual(mockResult);
const expectedViewModel = {
entityType: 'season',
entityId: 'season-1',
pricing: []
};
expect(presenter.viewModel).toEqual(expectedViewModel);
presenter.reset();
expect(() => presenter.viewModel).toThrow('Presenter not presented');
@@ -21,11 +33,21 @@ describe('GetEntitySponsorshipPricingPresenter', () => {
describe('present', () => {
it('should store the result', () => {
const mockResult = { entityType: 'season', entityId: 'season-1', pricing: [] };
const mockResult: GetEntitySponsorshipPricingResult = {
entityType: 'season',
entityId: 'season-1',
acceptingApplications: true,
tiers: []
};
presenter.present(mockResult);
expect(presenter.viewModel).toEqual(mockResult);
const expectedViewModel = {
entityType: 'season',
entityId: 'season-1',
pricing: []
};
expect(presenter.viewModel).toEqual(expectedViewModel);
});
});
@@ -35,10 +57,20 @@ describe('GetEntitySponsorshipPricingPresenter', () => {
});
it('should return the result when presented', () => {
const mockResult = { entityType: 'season', entityId: 'season-1', pricing: [] };
const mockResult: GetEntitySponsorshipPricingResult = {
entityType: 'season',
entityId: 'season-1',
acceptingApplications: true,
tiers: []
};
presenter.present(mockResult);
expect(presenter.getViewModel()).toEqual(mockResult);
const expectedViewModel = {
entityType: 'season',
entityId: 'season-1',
pricing: []
};
expect(presenter.getViewModel()).toEqual(expectedViewModel);
});
});
@@ -48,10 +80,20 @@ describe('GetEntitySponsorshipPricingPresenter', () => {
});
it('should return the result when presented', () => {
const mockResult = { entityType: 'season', entityId: 'season-1', pricing: [] };
const mockResult: GetEntitySponsorshipPricingResult = {
entityType: 'season',
entityId: 'season-1',
acceptingApplications: true,
tiers: []
};
presenter.present(mockResult);
expect(presenter.viewModel).toEqual(mockResult);
const expectedViewModel = {
entityType: 'season',
entityId: 'season-1',
pricing: []
};
expect(presenter.viewModel).toEqual(expectedViewModel);
});
});
});