integration tests
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
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
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m50s
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
This commit is contained in:
70
tests/integration/leagues/LeaguesTestContext.ts
Normal file
70
tests/integration/leagues/LeaguesTestContext.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { InMemoryLeagueRepository } from '../../../adapters/leagues/persistence/inmemory/InMemoryLeagueRepository';
|
||||
import { InMemoryDriverRepository } from '../../../adapters/drivers/persistence/inmemory/InMemoryDriverRepository';
|
||||
import { InMemoryEventPublisher } from '../../../adapters/events/InMemoryEventPublisher';
|
||||
import { CreateLeagueUseCase } from '../../../core/leagues/application/use-cases/CreateLeagueUseCase';
|
||||
import { GetLeagueUseCase } from '../../../core/leagues/application/use-cases/GetLeagueUseCase';
|
||||
import { GetLeagueRosterUseCase } from '../../../core/leagues/application/use-cases/GetLeagueRosterUseCase';
|
||||
import { JoinLeagueUseCase } from '../../../core/leagues/application/use-cases/JoinLeagueUseCase';
|
||||
import { LeaveLeagueUseCase } from '../../../core/leagues/application/use-cases/LeaveLeagueUseCase';
|
||||
import { ApproveMembershipRequestUseCase } from '../../../core/leagues/application/use-cases/ApproveMembershipRequestUseCase';
|
||||
import { RejectMembershipRequestUseCase } from '../../../core/leagues/application/use-cases/RejectMembershipRequestUseCase';
|
||||
import { PromoteMemberUseCase } from '../../../core/leagues/application/use-cases/PromoteMemberUseCase';
|
||||
import { DemoteAdminUseCase } from '../../../core/leagues/application/use-cases/DemoteAdminUseCase';
|
||||
import { RemoveMemberUseCase } from '../../../core/leagues/application/use-cases/RemoveMemberUseCase';
|
||||
import { LeagueCreateCommand } from '../../../core/leagues/application/ports/LeagueCreateCommand';
|
||||
|
||||
export class LeaguesTestContext {
|
||||
public readonly leagueRepository: InMemoryLeagueRepository;
|
||||
public readonly driverRepository: InMemoryDriverRepository;
|
||||
public readonly eventPublisher: InMemoryEventPublisher;
|
||||
|
||||
public readonly createLeagueUseCase: CreateLeagueUseCase;
|
||||
public readonly getLeagueUseCase: GetLeagueUseCase;
|
||||
public readonly getLeagueRosterUseCase: GetLeagueRosterUseCase;
|
||||
public readonly joinLeagueUseCase: JoinLeagueUseCase;
|
||||
public readonly leaveLeagueUseCase: LeaveLeagueUseCase;
|
||||
public readonly approveMembershipRequestUseCase: ApproveMembershipRequestUseCase;
|
||||
public readonly rejectMembershipRequestUseCase: RejectMembershipRequestUseCase;
|
||||
public readonly promoteMemberUseCase: PromoteMemberUseCase;
|
||||
public readonly demoteAdminUseCase: DemoteAdminUseCase;
|
||||
public readonly removeMemberUseCase: RemoveMemberUseCase;
|
||||
|
||||
constructor() {
|
||||
this.leagueRepository = new InMemoryLeagueRepository();
|
||||
this.driverRepository = new InMemoryDriverRepository();
|
||||
this.eventPublisher = new InMemoryEventPublisher();
|
||||
|
||||
this.createLeagueUseCase = new CreateLeagueUseCase(this.leagueRepository, this.eventPublisher);
|
||||
this.getLeagueUseCase = new GetLeagueUseCase(this.leagueRepository, this.eventPublisher);
|
||||
this.getLeagueRosterUseCase = new GetLeagueRosterUseCase(this.leagueRepository, this.eventPublisher);
|
||||
this.joinLeagueUseCase = new JoinLeagueUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher);
|
||||
this.leaveLeagueUseCase = new LeaveLeagueUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher);
|
||||
this.approveMembershipRequestUseCase = new ApproveMembershipRequestUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher);
|
||||
this.rejectMembershipRequestUseCase = new RejectMembershipRequestUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher);
|
||||
this.promoteMemberUseCase = new PromoteMemberUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher);
|
||||
this.demoteAdminUseCase = new DemoteAdminUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher);
|
||||
this.removeMemberUseCase = new RemoveMemberUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher);
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
this.leagueRepository.clear();
|
||||
this.driverRepository.clear();
|
||||
this.eventPublisher.clear();
|
||||
}
|
||||
|
||||
public async createLeague(command: Partial<LeagueCreateCommand> = {}) {
|
||||
const defaultCommand: LeagueCreateCommand = {
|
||||
name: 'Test League',
|
||||
visibility: 'public',
|
||||
ownerId: 'driver-123',
|
||||
approvalRequired: false,
|
||||
lateJoinAllowed: false,
|
||||
bonusPointsEnabled: false,
|
||||
penaltiesEnabled: false,
|
||||
protestsEnabled: false,
|
||||
appealsEnabled: false,
|
||||
...command,
|
||||
};
|
||||
return await this.createLeagueUseCase.execute(defaultCommand);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user