fix issues in core
This commit is contained in:
@@ -5,16 +5,12 @@ import {
|
||||
type GetEntitySponsorshipPricingResult,
|
||||
} from './GetEntitySponsorshipPricingUseCase';
|
||||
import type { ISponsorshipPricingRepository } from '../../domain/repositories/ISponsorshipPricingRepository';
|
||||
import type { ISponsorshipRequestRepository } from '../../domain/repositories/ISponsorshipRequestRepository';
|
||||
import type { ISeasonSponsorshipRepository } from '../../domain/repositories/ISeasonSponsorshipRepository';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
import type { UseCaseOutputPort } from '@core/shared/application/UseCaseOutputPort';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
|
||||
describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
let mockSponsorshipPricingRepo: ISponsorshipPricingRepository;
|
||||
let mockSponsorshipRequestRepo: ISponsorshipRequestRepository;
|
||||
let mockSeasonSponsorshipRepo: ISeasonSponsorshipRepository;
|
||||
let mockLogger: Logger;
|
||||
let mockFindByEntity: Mock;
|
||||
let mockFindPendingByEntity: Mock;
|
||||
@@ -37,37 +33,6 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
exists: vi.fn(),
|
||||
findAcceptingApplications: vi.fn(),
|
||||
} as ISponsorshipPricingRepository;
|
||||
mockSponsorshipRequestRepo = {
|
||||
findPendingByEntity: mockFindPendingByEntity,
|
||||
findByEntity: vi.fn(),
|
||||
findById: vi.fn(),
|
||||
save: vi.fn(),
|
||||
update: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
findBySponsorId: vi.fn(),
|
||||
findByStatus: vi.fn(),
|
||||
findBySponsorIdAndStatus: vi.fn(),
|
||||
hasPendingRequest: vi.fn(),
|
||||
findPendingBySponsor: vi.fn(),
|
||||
findApprovedByEntity: vi.fn(),
|
||||
findRejectedByEntity: vi.fn(),
|
||||
countPendingByEntity: vi.fn(),
|
||||
create: vi.fn(),
|
||||
exists: vi.fn(),
|
||||
} as ISponsorshipRequestRepository;
|
||||
mockSeasonSponsorshipRepo = {
|
||||
findBySeasonId: mockFindBySeasonId,
|
||||
findById: vi.fn(),
|
||||
save: vi.fn(),
|
||||
update: vi.fn(),
|
||||
delete: vi.fn(),
|
||||
findAll: vi.fn(),
|
||||
findByLeagueId: vi.fn(),
|
||||
findBySponsorId: vi.fn(),
|
||||
findBySeasonAndTier: vi.fn(),
|
||||
create: vi.fn(),
|
||||
exists: vi.fn(),
|
||||
} as ISeasonSponsorshipRepository;
|
||||
mockLogger = {
|
||||
debug: vi.fn(),
|
||||
info: vi.fn(),
|
||||
@@ -80,8 +45,6 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
it('should return PRICING_NOT_CONFIGURED when no pricing found', async () => {
|
||||
const useCase = new GetEntitySponsorshipPricingUseCase(
|
||||
mockSponsorshipPricingRepo as unknown as ISponsorshipPricingRepository,
|
||||
mockSponsorshipRequestRepo as unknown as ISponsorshipRequestRepository,
|
||||
mockSeasonSponsorshipRepo as unknown as ISeasonSponsorshipRepository,
|
||||
mockLogger,
|
||||
output,
|
||||
);
|
||||
@@ -108,8 +71,6 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
it('should return pricing data when found', async () => {
|
||||
const useCase = new GetEntitySponsorshipPricingUseCase(
|
||||
mockSponsorshipPricingRepo as unknown as ISponsorshipPricingRepository,
|
||||
mockSponsorshipRequestRepo as unknown as ISponsorshipRequestRepository,
|
||||
mockSeasonSponsorshipRepo as unknown as ISeasonSponsorshipRepository,
|
||||
mockLogger,
|
||||
output,
|
||||
);
|
||||
@@ -118,6 +79,7 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
entityType: 'season',
|
||||
entityId: 'season1',
|
||||
};
|
||||
|
||||
const pricing = {
|
||||
acceptingApplications: true,
|
||||
customRequirements: 'Some requirements',
|
||||
@@ -145,7 +107,7 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
expect(result.unwrap()).toBeUndefined();
|
||||
expect(output.present).toHaveBeenCalledTimes(1);
|
||||
|
||||
const presented = (output.present as Mock).mock.calls[0][0] as GetEntitySponsorshipPricingResult;
|
||||
const presented = (output.present as Mock).mock.calls[0]?.[0] as GetEntitySponsorshipPricingResult;
|
||||
|
||||
expect(presented.entityType).toBe('season');
|
||||
expect(presented.entityId).toBe('season1');
|
||||
@@ -170,8 +132,6 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
it('should return error when repository throws', async () => {
|
||||
const useCase = new GetEntitySponsorshipPricingUseCase(
|
||||
mockSponsorshipPricingRepo as unknown as ISponsorshipPricingRepository,
|
||||
mockSponsorshipRequestRepo as unknown as ISponsorshipRequestRepository,
|
||||
mockSeasonSponsorshipRepo as unknown as ISeasonSponsorshipRepository,
|
||||
mockLogger,
|
||||
output,
|
||||
);
|
||||
@@ -180,6 +140,7 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
entityType: 'season',
|
||||
entityId: 'season1',
|
||||
};
|
||||
|
||||
const error = new Error('Repository error');
|
||||
|
||||
mockFindByEntity.mockRejectedValue(error);
|
||||
@@ -195,4 +156,4 @@ describe('GetEntitySponsorshipPricingUseCase', () => {
|
||||
expect(err.details.message).toBe('Repository error');
|
||||
expect(output.present).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user