Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
65 lines
2.4 KiB
TypeScript
65 lines
2.4 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import { GetEntitySponsorshipPricingUseCase } from '../../../../core/racing/application/use-cases/GetEntitySponsorshipPricingUseCase';
|
|
import { SponsorTestContext } from '../SponsorTestContext';
|
|
|
|
describe('Sponsor League Detail Use Case Orchestration', () => {
|
|
let context: SponsorTestContext;
|
|
let getEntitySponsorshipPricingUseCase: GetEntitySponsorshipPricingUseCase;
|
|
|
|
beforeEach(() => {
|
|
context = new SponsorTestContext();
|
|
getEntitySponsorshipPricingUseCase = new GetEntitySponsorshipPricingUseCase(
|
|
context.sponsorshipPricingRepository,
|
|
context.logger,
|
|
);
|
|
});
|
|
|
|
describe('GetEntitySponsorshipPricingUseCase - Success Path', () => {
|
|
it('should retrieve sponsorship pricing for a league', async () => {
|
|
const leagueId = 'league-123';
|
|
const pricing = {
|
|
entityType: 'league' as const,
|
|
entityId: leagueId,
|
|
acceptingApplications: true,
|
|
mainSlot: {
|
|
price: { amount: 10000, currency: 'USD' },
|
|
benefits: ['Primary logo placement', 'League page header banner'],
|
|
},
|
|
secondarySlots: {
|
|
price: { amount: 2000, currency: 'USD' },
|
|
benefits: ['Secondary logo on liveries', 'League page sidebar placement'],
|
|
},
|
|
};
|
|
await context.sponsorshipPricingRepository.create(pricing);
|
|
|
|
const result = await getEntitySponsorshipPricingUseCase.execute({
|
|
entityType: 'league',
|
|
entityId: leagueId,
|
|
});
|
|
|
|
expect(result.isOk()).toBe(true);
|
|
const pricingResult = result.unwrap();
|
|
|
|
expect(pricingResult.entityType).toBe('league');
|
|
expect(pricingResult.entityId).toBe(leagueId);
|
|
expect(pricingResult.acceptingApplications).toBe(true);
|
|
expect(pricingResult.tiers).toHaveLength(2);
|
|
expect(pricingResult.tiers[0]!.name).toBe('main');
|
|
expect(pricingResult.tiers[0].price.amount).toBe(10000);
|
|
});
|
|
});
|
|
|
|
describe('GetEntitySponsorshipPricingUseCase - Error Handling', () => {
|
|
it('should return error when pricing is not configured', async () => {
|
|
const result = await getEntitySponsorshipPricingUseCase.execute({
|
|
entityType: 'season',
|
|
entityId: 'non-existent',
|
|
});
|
|
|
|
expect(result.isErr()).toBe(true);
|
|
const error = result.unwrapErr();
|
|
expect(error.code).toBe('PRICING_NOT_CONFIGURED');
|
|
});
|
|
});
|
|
});
|