Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
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
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import { LeaderboardsTestContext } from '../LeaderboardsTestContext';
|
|
|
|
describe('GetTeamRankingsUseCase - Data Orchestration', () => {
|
|
let context: LeaderboardsTestContext;
|
|
|
|
beforeEach(() => {
|
|
context = LeaderboardsTestContext.create();
|
|
context.clear();
|
|
});
|
|
|
|
it('should correctly calculate team rankings based on rating', async () => {
|
|
const ratings = [4.9, 4.7, 4.6, 4.3, 4.1];
|
|
ratings.forEach((rating, index) => {
|
|
context.repository.addTeam({
|
|
id: `team-${index}`,
|
|
name: `Team ${index}`,
|
|
rating,
|
|
memberCount: 2 + index,
|
|
raceCount: 20 + index,
|
|
});
|
|
});
|
|
|
|
const result = await context.getTeamRankingsUseCase.execute({});
|
|
|
|
expect(result.teams[0]!.rank).toBe(1);
|
|
expect(result.teams[0]!.rating).toBe(4.9);
|
|
expect(result.teams[4]!.rank).toBe(5);
|
|
expect(result.teams[4]!.rating).toBe(4.1);
|
|
});
|
|
|
|
it('should correctly aggregate member counts from drivers', async () => {
|
|
// Scenario: Member count aggregation
|
|
// Given: A team exists with 5 drivers
|
|
// And: Each driver is affiliated with the team
|
|
for (let i = 1; i <= 5; i++) {
|
|
context.repository.addDriver({
|
|
id: `driver-${i}`,
|
|
name: `Driver ${i}`,
|
|
rating: 5.0 - i * 0.1,
|
|
teamId: 'team-1',
|
|
teamName: 'Team 1',
|
|
raceCount: 10,
|
|
});
|
|
}
|
|
|
|
const result = await context.getTeamRankingsUseCase.execute({});
|
|
|
|
expect(result.teams[0]!.memberCount).toBe(5);
|
|
});
|
|
});
|