Files
gridpilot.gg/tests/integration/profile/use-cases/GetLeagueMembershipsUseCase.test.ts
Marc Mintel 6df38a462a
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
integration tests
2026-01-23 11:44:59 +01:00

51 lines
1.9 KiB
TypeScript

import { describe, it, expect, beforeEach } from 'vitest';
import { ProfileTestContext } from '../ProfileTestContext';
import { GetLeagueMembershipsUseCase } from '../../../../core/racing/application/use-cases/GetLeagueMembershipsUseCase';
import { Driver } from '../../../../core/racing/domain/entities/Driver';
import { League } from '../../../../core/racing/domain/entities/League';
import { LeagueMembership } from '../../../../core/racing/domain/entities/LeagueMembership';
describe('GetLeagueMembershipsUseCase', () => {
let context: ProfileTestContext;
let useCase: GetLeagueMembershipsUseCase;
beforeEach(async () => {
context = new ProfileTestContext();
useCase = new GetLeagueMembershipsUseCase(
context.leagueMembershipRepository,
context.driverRepository,
context.leagueRepository
);
await context.clear();
});
it('should retrieve league memberships for a league', async () => {
// Given: A league with members
const leagueId = 'lg1';
const driverId = 'd4';
const league = League.create({ id: leagueId, name: 'League 1', description: 'Desc', ownerId: 'owner' });
await context.leagueRepository.create(league);
const membership = LeagueMembership.create({
id: 'm1',
leagueId,
driverId,
role: 'member',
status: 'active'
});
await context.leagueMembershipRepository.saveMembership(membership);
const driver = Driver.create({ id: driverId, iracingId: '4', name: 'Member Driver', country: 'US' });
await context.driverRepository.create(driver);
// When: GetLeagueMembershipsUseCase.execute() is called
const result = await useCase.execute({ leagueId });
// Then: It should return the memberships with driver info
expect(result.isOk()).toBe(true);
const data = result.unwrap();
expect(data.memberships).toHaveLength(1);
expect(data.memberships[0].driver?.id).toBe(driverId);
});
});