integration tests
This commit is contained in:
239
tests/integration/leagues/schedule/GetLeagueSchedule.test.ts
Normal file
239
tests/integration/leagues/schedule/GetLeagueSchedule.test.ts
Normal file
@@ -0,0 +1,239 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { LeaguesTestContext } from '../LeaguesTestContext';
|
||||
import { League as RacingLeague } from '../../../../core/racing/domain/entities/League';
|
||||
import { Season } from '../../../../core/racing/domain/entities/season/Season';
|
||||
import { Race } from '../../../../core/racing/domain/entities/Race';
|
||||
|
||||
describe('League Schedule - GetLeagueScheduleUseCase', () => {
|
||||
let context: LeaguesTestContext;
|
||||
|
||||
beforeEach(() => {
|
||||
context = new LeaguesTestContext();
|
||||
context.clear();
|
||||
});
|
||||
|
||||
const seedRacingLeague = async (params: { leagueId: string }) => {
|
||||
const league = RacingLeague.create({
|
||||
id: params.leagueId,
|
||||
name: 'Racing League',
|
||||
description: 'League used for schedule integration tests',
|
||||
ownerId: 'driver-123',
|
||||
});
|
||||
|
||||
await context.racingLeagueRepository.create(league);
|
||||
return league;
|
||||
};
|
||||
|
||||
const seedSeason = async (params: {
|
||||
seasonId: string;
|
||||
leagueId: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
status?: 'planned' | 'active' | 'completed' | 'archived' | 'cancelled';
|
||||
schedulePublished?: boolean;
|
||||
}) => {
|
||||
const season = Season.create({
|
||||
id: params.seasonId,
|
||||
leagueId: params.leagueId,
|
||||
gameId: 'iracing',
|
||||
name: 'Season 1',
|
||||
status: params.status ?? 'active',
|
||||
startDate: params.startDate,
|
||||
endDate: params.endDate,
|
||||
...(params.schedulePublished !== undefined ? { schedulePublished: params.schedulePublished } : {}),
|
||||
});
|
||||
|
||||
await context.seasonRepository.add(season);
|
||||
return season;
|
||||
};
|
||||
|
||||
it('returns schedule for active season and races within season window', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
const seasonId = 'season-jan';
|
||||
await seedSeason({
|
||||
seasonId,
|
||||
leagueId,
|
||||
startDate: new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: new Date('2025-01-31T23:59:59Z'),
|
||||
status: 'active',
|
||||
});
|
||||
|
||||
const createRace1 = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Track A',
|
||||
car: 'Car A',
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
});
|
||||
expect(createRace1.isOk()).toBe(true);
|
||||
|
||||
const createRace2 = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Track B',
|
||||
car: 'Car B',
|
||||
scheduledAt: new Date('2025-01-20T20:00:00Z'),
|
||||
});
|
||||
expect(createRace2.isOk()).toBe(true);
|
||||
|
||||
const result = await context.getLeagueScheduleUseCase.execute({ leagueId });
|
||||
|
||||
expect(result.isOk()).toBe(true);
|
||||
const value = result.unwrap();
|
||||
expect(value.league.id.toString()).toBe(leagueId);
|
||||
expect(value.seasonId).toBe(seasonId);
|
||||
expect(value.published).toBe(false);
|
||||
expect(value.races.map(r => r.race.track)).toEqual(['Track A', 'Track B']);
|
||||
});
|
||||
|
||||
it('scopes schedule by seasonId (no season date bleed)', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
const janSeasonId = 'season-jan';
|
||||
const febSeasonId = 'season-feb';
|
||||
|
||||
await seedSeason({
|
||||
seasonId: janSeasonId,
|
||||
leagueId,
|
||||
startDate: new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: new Date('2025-01-31T23:59:59Z'),
|
||||
status: 'active',
|
||||
});
|
||||
|
||||
await seedSeason({
|
||||
seasonId: febSeasonId,
|
||||
leagueId,
|
||||
startDate: new Date('2025-02-01T00:00:00Z'),
|
||||
endDate: new Date('2025-02-28T23:59:59Z'),
|
||||
status: 'planned',
|
||||
});
|
||||
|
||||
const janRace = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId: janSeasonId,
|
||||
track: 'Track Jan',
|
||||
car: 'Car Jan',
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
});
|
||||
expect(janRace.isOk()).toBe(true);
|
||||
|
||||
const febRace = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId: febSeasonId,
|
||||
track: 'Track Feb',
|
||||
car: 'Car Feb',
|
||||
scheduledAt: new Date('2025-02-10T20:00:00Z'),
|
||||
});
|
||||
expect(febRace.isOk()).toBe(true);
|
||||
|
||||
const janResult = await context.getLeagueScheduleUseCase.execute({
|
||||
leagueId,
|
||||
seasonId: janSeasonId,
|
||||
});
|
||||
|
||||
expect(janResult.isOk()).toBe(true);
|
||||
const janValue = janResult.unwrap();
|
||||
expect(janValue.seasonId).toBe(janSeasonId);
|
||||
expect(janValue.races.map(r => r.race.track)).toEqual(['Track Jan']);
|
||||
|
||||
const febResult = await context.getLeagueScheduleUseCase.execute({
|
||||
leagueId,
|
||||
seasonId: febSeasonId,
|
||||
});
|
||||
|
||||
expect(febResult.isOk()).toBe(true);
|
||||
const febValue = febResult.unwrap();
|
||||
expect(febValue.seasonId).toBe(febSeasonId);
|
||||
expect(febValue.races.map(r => r.race.track)).toEqual(['Track Feb']);
|
||||
});
|
||||
|
||||
it('returns all races when no seasons exist for league', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
await context.raceRepository.create(
|
||||
Race.create({
|
||||
id: 'race-1',
|
||||
leagueId,
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
track: 'Track 1',
|
||||
car: 'Car 1',
|
||||
}),
|
||||
);
|
||||
|
||||
await context.raceRepository.create(
|
||||
Race.create({
|
||||
id: 'race-2',
|
||||
leagueId,
|
||||
scheduledAt: new Date('2025-01-15T20:00:00Z'),
|
||||
track: 'Track 2',
|
||||
car: 'Car 2',
|
||||
}),
|
||||
);
|
||||
|
||||
const result = await context.getLeagueScheduleUseCase.execute({ leagueId });
|
||||
|
||||
expect(result.isOk()).toBe(true);
|
||||
const value = result.unwrap();
|
||||
expect(value.seasonId).toBe('no-season');
|
||||
expect(value.published).toBe(false);
|
||||
expect(value.races.map(r => r.race.track)).toEqual(['Track 1', 'Track 2']);
|
||||
});
|
||||
|
||||
it('reflects schedule published state from the selected season', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
const seasonId = 'season-1';
|
||||
await seedSeason({
|
||||
seasonId,
|
||||
leagueId,
|
||||
startDate: new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: new Date('2025-01-31T23:59:59Z'),
|
||||
status: 'active',
|
||||
schedulePublished: false,
|
||||
});
|
||||
|
||||
const pre = await context.getLeagueScheduleUseCase.execute({ leagueId });
|
||||
expect(pre.isOk()).toBe(true);
|
||||
expect(pre.unwrap().published).toBe(false);
|
||||
|
||||
const publish = await context.publishLeagueSeasonScheduleUseCase.execute({ leagueId, seasonId });
|
||||
expect(publish.isOk()).toBe(true);
|
||||
|
||||
const post = await context.getLeagueScheduleUseCase.execute({ leagueId });
|
||||
expect(post.isOk()).toBe(true);
|
||||
expect(post.unwrap().published).toBe(true);
|
||||
});
|
||||
|
||||
it('returns LEAGUE_NOT_FOUND when league does not exist', async () => {
|
||||
const result = await context.getLeagueScheduleUseCase.execute({ leagueId: 'missing-league' });
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().code).toBe('LEAGUE_NOT_FOUND');
|
||||
});
|
||||
|
||||
it('returns SEASON_NOT_FOUND when requested season does not belong to the league', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
await seedSeason({
|
||||
seasonId: 'season-other',
|
||||
leagueId: 'league-other',
|
||||
startDate: new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: new Date('2025-01-31T23:59:59Z'),
|
||||
status: 'active',
|
||||
});
|
||||
|
||||
const result = await context.getLeagueScheduleUseCase.execute({
|
||||
leagueId,
|
||||
seasonId: 'season-other',
|
||||
});
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().code).toBe('SEASON_NOT_FOUND');
|
||||
});
|
||||
});
|
||||
174
tests/integration/leagues/schedule/RaceManagement.test.ts
Normal file
174
tests/integration/leagues/schedule/RaceManagement.test.ts
Normal file
@@ -0,0 +1,174 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { LeaguesTestContext } from '../LeaguesTestContext';
|
||||
import { League as RacingLeague } from '../../../../core/racing/domain/entities/League';
|
||||
import { Season } from '../../../../core/racing/domain/entities/season/Season';
|
||||
|
||||
describe('League Schedule - Race Management', () => {
|
||||
let context: LeaguesTestContext;
|
||||
|
||||
beforeEach(() => {
|
||||
context = new LeaguesTestContext();
|
||||
context.clear();
|
||||
});
|
||||
|
||||
const seedRacingLeague = async (params: { leagueId: string }) => {
|
||||
const league = RacingLeague.create({
|
||||
id: params.leagueId,
|
||||
name: 'Racing League',
|
||||
description: 'League used for schedule integration tests',
|
||||
ownerId: 'driver-123',
|
||||
});
|
||||
|
||||
await context.racingLeagueRepository.create(league);
|
||||
return league;
|
||||
};
|
||||
|
||||
const seedSeason = async (params: {
|
||||
seasonId: string;
|
||||
leagueId: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
status?: 'planned' | 'active' | 'completed' | 'archived' | 'cancelled';
|
||||
}) => {
|
||||
const season = Season.create({
|
||||
id: params.seasonId,
|
||||
leagueId: params.leagueId,
|
||||
gameId: 'iracing',
|
||||
name: 'Season 1',
|
||||
status: params.status ?? 'active',
|
||||
startDate: params.startDate,
|
||||
endDate: params.endDate,
|
||||
});
|
||||
|
||||
await context.seasonRepository.add(season);
|
||||
return season;
|
||||
};
|
||||
|
||||
it('creates a race in a season schedule', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
const seasonId = 'season-1';
|
||||
await seedSeason({
|
||||
seasonId,
|
||||
leagueId,
|
||||
startDate: new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: new Date('2025-01-31T23:59:59Z'),
|
||||
});
|
||||
|
||||
const create = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Monza',
|
||||
car: 'GT3',
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
});
|
||||
|
||||
expect(create.isOk()).toBe(true);
|
||||
const { raceId } = create.unwrap();
|
||||
|
||||
const schedule = await context.getLeagueScheduleUseCase.execute({ leagueId, seasonId });
|
||||
expect(schedule.isOk()).toBe(true);
|
||||
expect(schedule.unwrap().races.map(r => r.race.id)).toEqual([raceId]);
|
||||
});
|
||||
|
||||
it('updates an existing scheduled race (track/car/when)', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
const seasonId = 'season-1';
|
||||
await seedSeason({
|
||||
seasonId,
|
||||
leagueId,
|
||||
startDate: new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: new Date('2025-01-31T23:59:59Z'),
|
||||
});
|
||||
|
||||
const create = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Old Track',
|
||||
car: 'Old Car',
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
});
|
||||
expect(create.isOk()).toBe(true);
|
||||
const { raceId } = create.unwrap();
|
||||
|
||||
const update = await context.updateLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
raceId,
|
||||
track: 'New Track',
|
||||
car: 'New Car',
|
||||
scheduledAt: new Date('2025-01-20T20:00:00Z'),
|
||||
});
|
||||
|
||||
expect(update.isOk()).toBe(true);
|
||||
|
||||
const schedule = await context.getLeagueScheduleUseCase.execute({ leagueId, seasonId });
|
||||
expect(schedule.isOk()).toBe(true);
|
||||
const race = schedule.unwrap().races[0]?.race;
|
||||
expect(race?.id).toBe(raceId);
|
||||
expect(race?.track).toBe('New Track');
|
||||
expect(race?.car).toBe('New Car');
|
||||
expect(race?.scheduledAt.toISOString()).toBe('2025-01-20T20:00:00.000Z');
|
||||
});
|
||||
|
||||
it('deletes a scheduled race from the season', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
const seasonId = 'season-1';
|
||||
await seedSeason({
|
||||
seasonId,
|
||||
leagueId,
|
||||
startDate: new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: new Date('2025-01-31T23:59:59Z'),
|
||||
});
|
||||
|
||||
const create = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Track 1',
|
||||
car: 'Car 1',
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
});
|
||||
expect(create.isOk()).toBe(true);
|
||||
const { raceId } = create.unwrap();
|
||||
|
||||
const pre = await context.getLeagueScheduleUseCase.execute({ leagueId, seasonId });
|
||||
expect(pre.isOk()).toBe(true);
|
||||
expect(pre.unwrap().races.map(r => r.race.id)).toEqual([raceId]);
|
||||
|
||||
const del = await context.deleteLeagueSeasonScheduleRaceUseCase.execute({ leagueId, seasonId, raceId });
|
||||
expect(del.isOk()).toBe(true);
|
||||
|
||||
const post = await context.getLeagueScheduleUseCase.execute({ leagueId, seasonId });
|
||||
expect(post.isOk()).toBe(true);
|
||||
expect(post.unwrap().races).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('rejects creating a race outside the season window', async () => {
|
||||
const leagueId = 'league-1';
|
||||
await seedRacingLeague({ leagueId });
|
||||
|
||||
const seasonId = 'season-1';
|
||||
await seedSeason({
|
||||
seasonId,
|
||||
leagueId,
|
||||
startDate: new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: new Date('2025-01-31T23:59:59Z'),
|
||||
});
|
||||
|
||||
const create = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Track',
|
||||
car: 'Car',
|
||||
scheduledAt: new Date('2025-02-10T20:00:00Z'),
|
||||
});
|
||||
|
||||
expect(create.isErr()).toBe(true);
|
||||
expect(create.unwrapErr().code).toBe('RACE_OUTSIDE_SEASON_WINDOW');
|
||||
});
|
||||
});
|
||||
178
tests/integration/leagues/schedule/RaceRegistration.test.ts
Normal file
178
tests/integration/leagues/schedule/RaceRegistration.test.ts
Normal file
@@ -0,0 +1,178 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
import { LeaguesTestContext } from '../LeaguesTestContext';
|
||||
import { League as RacingLeague } from '../../../../core/racing/domain/entities/League';
|
||||
import { Season } from '../../../../core/racing/domain/entities/season/Season';
|
||||
import { LeagueMembership } from '../../../../core/racing/domain/entities/LeagueMembership';
|
||||
|
||||
// Note: the current racing module does not expose explicit "open/close registration" use-cases.
|
||||
// Registration is modeled via membership + registrations repository interactions.
|
||||
|
||||
describe('League Schedule - Race Registration', () => {
|
||||
let context: LeaguesTestContext;
|
||||
|
||||
beforeEach(() => {
|
||||
context = new LeaguesTestContext();
|
||||
context.clear();
|
||||
});
|
||||
|
||||
const seedRacingLeague = async (params: { leagueId: string }) => {
|
||||
const league = RacingLeague.create({
|
||||
id: params.leagueId,
|
||||
name: 'Racing League',
|
||||
description: 'League used for registration integration tests',
|
||||
ownerId: 'driver-123',
|
||||
});
|
||||
|
||||
await context.racingLeagueRepository.create(league);
|
||||
return league;
|
||||
};
|
||||
|
||||
const seedSeason = async (params: {
|
||||
seasonId: string;
|
||||
leagueId: string;
|
||||
startDate?: Date;
|
||||
endDate?: Date;
|
||||
}) => {
|
||||
const season = Season.create({
|
||||
id: params.seasonId,
|
||||
leagueId: params.leagueId,
|
||||
gameId: 'iracing',
|
||||
name: 'Season 1',
|
||||
status: 'active',
|
||||
startDate: params.startDate ?? new Date('2025-01-01T00:00:00Z'),
|
||||
endDate: params.endDate ?? new Date('2025-01-31T23:59:59Z'),
|
||||
});
|
||||
|
||||
await context.seasonRepository.add(season);
|
||||
return season;
|
||||
};
|
||||
|
||||
const seedActiveMembership = async (params: { leagueId: string; driverId: string }) => {
|
||||
const membership = LeagueMembership.create({
|
||||
leagueId: params.leagueId,
|
||||
driverId: params.driverId,
|
||||
role: 'member',
|
||||
status: 'active',
|
||||
});
|
||||
|
||||
await context.leagueMembershipRepository.saveMembership(membership);
|
||||
return membership;
|
||||
};
|
||||
|
||||
it('registers an active league member for a race', async () => {
|
||||
const leagueId = 'league-1';
|
||||
const seasonId = 'season-1';
|
||||
const driverId = 'driver-1';
|
||||
|
||||
await seedRacingLeague({ leagueId });
|
||||
await seedSeason({ leagueId, seasonId });
|
||||
await seedActiveMembership({ leagueId, driverId });
|
||||
|
||||
const createRace = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Monza',
|
||||
car: 'GT3',
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
});
|
||||
expect(createRace.isOk()).toBe(true);
|
||||
const { raceId } = createRace.unwrap();
|
||||
|
||||
const register = await context.registerForRaceUseCase.execute({
|
||||
leagueId,
|
||||
raceId,
|
||||
driverId,
|
||||
});
|
||||
|
||||
expect(register.isOk()).toBe(true);
|
||||
expect(register.unwrap()).toEqual({ raceId, driverId, status: 'registered' });
|
||||
|
||||
const isRegistered = await context.raceRegistrationRepository.isRegistered(raceId, driverId);
|
||||
expect(isRegistered).toBe(true);
|
||||
});
|
||||
|
||||
it('rejects registration when driver is not an active member', async () => {
|
||||
const leagueId = 'league-1';
|
||||
const seasonId = 'season-1';
|
||||
|
||||
await seedRacingLeague({ leagueId });
|
||||
await seedSeason({ leagueId, seasonId });
|
||||
|
||||
const createRace = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Monza',
|
||||
car: 'GT3',
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
});
|
||||
expect(createRace.isOk()).toBe(true);
|
||||
|
||||
const { raceId } = createRace.unwrap();
|
||||
const result = await context.registerForRaceUseCase.execute({ leagueId, raceId, driverId: 'driver-missing' });
|
||||
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.unwrapErr().code).toBe('NOT_ACTIVE_MEMBER');
|
||||
});
|
||||
|
||||
it('rejects duplicate registration', async () => {
|
||||
const leagueId = 'league-1';
|
||||
const seasonId = 'season-1';
|
||||
const driverId = 'driver-1';
|
||||
|
||||
await seedRacingLeague({ leagueId });
|
||||
await seedSeason({ leagueId, seasonId });
|
||||
await seedActiveMembership({ leagueId, driverId });
|
||||
|
||||
const createRace = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Monza',
|
||||
car: 'GT3',
|
||||
scheduledAt: new Date('2025-01-10T20:00:00Z'),
|
||||
});
|
||||
expect(createRace.isOk()).toBe(true);
|
||||
const { raceId } = createRace.unwrap();
|
||||
|
||||
const first = await context.registerForRaceUseCase.execute({ leagueId, raceId, driverId });
|
||||
expect(first.isOk()).toBe(true);
|
||||
|
||||
const second = await context.registerForRaceUseCase.execute({ leagueId, raceId, driverId });
|
||||
expect(second.isErr()).toBe(true);
|
||||
expect(second.unwrapErr().code).toBe('ALREADY_REGISTERED');
|
||||
});
|
||||
|
||||
it('withdraws an existing registration for an upcoming race', async () => {
|
||||
const leagueId = 'league-1';
|
||||
const seasonId = 'season-1';
|
||||
const driverId = 'driver-1';
|
||||
|
||||
await seedRacingLeague({ leagueId });
|
||||
await seedSeason({
|
||||
leagueId,
|
||||
seasonId,
|
||||
startDate: new Date('2000-01-01T00:00:00Z'),
|
||||
endDate: new Date('2100-12-31T23:59:59Z'),
|
||||
});
|
||||
await seedActiveMembership({ leagueId, driverId });
|
||||
|
||||
const createRace = await context.createLeagueSeasonScheduleRaceUseCase.execute({
|
||||
leagueId,
|
||||
seasonId,
|
||||
track: 'Monza',
|
||||
car: 'GT3',
|
||||
scheduledAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
|
||||
});
|
||||
expect(createRace.isOk()).toBe(true);
|
||||
const { raceId } = createRace.unwrap();
|
||||
|
||||
const register = await context.registerForRaceUseCase.execute({ leagueId, raceId, driverId });
|
||||
expect(register.isOk()).toBe(true);
|
||||
|
||||
const withdraw = await context.withdrawFromRaceUseCase.execute({ raceId, driverId });
|
||||
expect(withdraw.isOk()).toBe(true);
|
||||
expect(withdraw.unwrap()).toEqual({ raceId, driverId, status: 'withdrawn' });
|
||||
|
||||
const isRegistered = await context.raceRegistrationRepository.isRegistered(raceId, driverId);
|
||||
expect(isRegistered).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user