Files
gridpilot.gg/tests/integration/dashboard/DashboardTestContext.ts
Marc Mintel a0f41f242f
Some checks failed
CI / lint-typecheck (pull_request) Failing after 4m51s
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 00:46:34 +01:00

58 lines
2.6 KiB
TypeScript

import { vi } from 'vitest';
import { InMemoryDriverRepository } from '../../../adapters/drivers/persistence/inmemory/InMemoryDriverRepository';
import { InMemoryRaceRepository } from '../../../adapters/races/persistence/inmemory/InMemoryRaceRepository';
import { InMemoryLeagueRepository } from '../../../adapters/leagues/persistence/inmemory/InMemoryLeagueRepository';
import { InMemoryActivityRepository } from '../../../adapters/activity/persistence/inmemory/InMemoryActivityRepository';
import { InMemoryEventPublisher } from '../../../adapters/events/InMemoryEventPublisher';
import { GetDashboardUseCase } from '../../../core/dashboard/application/use-cases/GetDashboardUseCase';
import { DashboardPresenter } from '../../../core/dashboard/application/presenters/DashboardPresenter';
import { DashboardRepository } from '../../../core/dashboard/application/ports/DashboardRepository';
export class DashboardTestContext {
public readonly driverRepository: InMemoryDriverRepository;
public readonly raceRepository: InMemoryRaceRepository;
public readonly leagueRepository: InMemoryLeagueRepository;
public readonly activityRepository: InMemoryActivityRepository;
public readonly eventPublisher: InMemoryEventPublisher;
public readonly getDashboardUseCase: GetDashboardUseCase;
public readonly dashboardPresenter: DashboardPresenter;
public readonly loggerMock: any;
constructor() {
this.driverRepository = new InMemoryDriverRepository();
this.raceRepository = new InMemoryRaceRepository();
this.leagueRepository = new InMemoryLeagueRepository();
this.activityRepository = new InMemoryActivityRepository();
this.eventPublisher = new InMemoryEventPublisher();
this.dashboardPresenter = new DashboardPresenter();
this.loggerMock = {
debug: vi.fn(),
info: vi.fn(),
warn: vi.fn(),
error: vi.fn(),
};
this.getDashboardUseCase = new GetDashboardUseCase({
driverRepository: this.driverRepository,
raceRepository: this.raceRepository as unknown as DashboardRepository,
leagueRepository: this.leagueRepository as unknown as DashboardRepository,
activityRepository: this.activityRepository as unknown as DashboardRepository,
eventPublisher: this.eventPublisher,
logger: this.loggerMock,
});
}
public clear(): void {
this.driverRepository.clear();
this.raceRepository.clear();
this.leagueRepository.clear();
this.activityRepository.clear();
this.eventPublisher.clear();
vi.clearAllMocks();
}
public static create(): DashboardTestContext {
return new DashboardTestContext();
}
}