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
72 lines
2.2 KiB
TypeScript
72 lines
2.2 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import { DashboardTestContext } from '../DashboardTestContext';
|
|
|
|
describe('Dashboard Data Flow Integration', () => {
|
|
const context = DashboardTestContext.create();
|
|
|
|
beforeEach(() => {
|
|
context.clear();
|
|
});
|
|
|
|
describe('Repository to Use Case Data Flow', () => {
|
|
it('should correctly flow driver data from repository to use case', async () => {
|
|
const driverId = 'driver-flow';
|
|
context.driverRepository.addDriver({
|
|
id: driverId,
|
|
name: 'Flow Driver',
|
|
rating: 1500,
|
|
rank: 123,
|
|
starts: 10,
|
|
wins: 3,
|
|
podiums: 5,
|
|
leagues: 1,
|
|
});
|
|
|
|
const result = await context.getDashboardUseCase.execute({ driverId });
|
|
|
|
expect(result.driver.id).toBe(driverId);
|
|
expect(result.driver.name).toBe('Flow Driver');
|
|
expect(result.statistics.rating).toBe(1500);
|
|
expect(result.statistics.rank).toBe(123);
|
|
expect(result.statistics.starts).toBe(10);
|
|
expect(result.statistics.wins).toBe(3);
|
|
expect(result.statistics.podiums).toBe(5);
|
|
});
|
|
});
|
|
|
|
describe('Complete Data Flow: Repository -> Use Case -> Presenter', () => {
|
|
it('should complete full data flow for driver with all data', async () => {
|
|
const driverId = 'driver-complete-flow';
|
|
context.driverRepository.addDriver({
|
|
id: driverId,
|
|
name: 'Complete Flow Driver',
|
|
avatar: 'https://example.com/avatar.jpg',
|
|
rating: 1600,
|
|
rank: 85,
|
|
starts: 25,
|
|
wins: 8,
|
|
podiums: 15,
|
|
leagues: 2,
|
|
});
|
|
|
|
context.raceRepository.addUpcomingRaces(driverId, [
|
|
{
|
|
id: 'race-1',
|
|
trackName: 'Monza',
|
|
carType: 'GT3',
|
|
scheduledDate: new Date(Date.now() + 2 * 24 * 60 * 60 * 1000),
|
|
},
|
|
]);
|
|
|
|
const result = await context.getDashboardUseCase.execute({ driverId });
|
|
const dto = context.dashboardPresenter.present(result);
|
|
|
|
expect(dto.driver.id).toBe(driverId);
|
|
expect(dto.driver.name).toBe('Complete Flow Driver');
|
|
expect(dto.statistics.rating).toBe(1600);
|
|
expect(dto.upcomingRaces).toHaveLength(1);
|
|
expect(dto.upcomingRaces[0].trackName).toBe('Monza');
|
|
});
|
|
});
|
|
});
|