wip
This commit is contained in:
@@ -19,10 +19,14 @@ class FakeDashboardOverviewPresenter implements IDashboardOverviewPresenter {
|
||||
}
|
||||
}
|
||||
|
||||
function createTestImageService() {
|
||||
interface TestImageService {
|
||||
getDriverAvatar(driverId: string): string;
|
||||
}
|
||||
|
||||
function createTestImageService(): TestImageService {
|
||||
return {
|
||||
getDriverAvatar: (driverId: string) => `avatar-${driverId}`,
|
||||
} as any;
|
||||
};
|
||||
}
|
||||
|
||||
describe('GetDashboardOverviewUseCase', () => {
|
||||
@@ -74,7 +78,7 @@ describe('GetDashboardOverviewUseCase', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const results: any[] = [];
|
||||
const results: unknown[] = [];
|
||||
|
||||
const memberships = [
|
||||
{
|
||||
@@ -92,29 +96,53 @@ describe('GetDashboardOverviewUseCase', () => {
|
||||
const registeredRaceIds = new Set<string>(['race-1', 'race-3']);
|
||||
|
||||
const feedItems: DashboardFeedItemSummaryViewModel[] = [];
|
||||
const friends: any[] = [];
|
||||
|
||||
const driverRepository = {
|
||||
const friends: Array<{ id: string }> = [];
|
||||
|
||||
const driverRepository: {
|
||||
findById: (id: string) => Promise<{ id: string; name: string; country: string } | null>;
|
||||
} = {
|
||||
findById: async (id: string) => (id === driver.id ? driver : null),
|
||||
} as any;
|
||||
|
||||
const raceRepository = {
|
||||
};
|
||||
|
||||
const raceRepository: {
|
||||
findAll: () => Promise<
|
||||
Array<{
|
||||
id: string;
|
||||
leagueId: string;
|
||||
track: string;
|
||||
car: string;
|
||||
scheduledAt: Date;
|
||||
status: 'scheduled';
|
||||
}>
|
||||
>;
|
||||
} = {
|
||||
findAll: async () => races,
|
||||
} as any;
|
||||
|
||||
const resultRepository = {
|
||||
};
|
||||
|
||||
const resultRepository: {
|
||||
findAll: () => Promise<unknown[]>;
|
||||
} = {
|
||||
findAll: async () => results,
|
||||
} as any;
|
||||
|
||||
const leagueRepository = {
|
||||
};
|
||||
|
||||
const leagueRepository: {
|
||||
findAll: () => Promise<Array<{ id: string; name: string }>>;
|
||||
} = {
|
||||
findAll: async () => leagues,
|
||||
} as any;
|
||||
|
||||
const standingRepository = {
|
||||
};
|
||||
|
||||
const standingRepository: {
|
||||
findByLeagueId: (leagueId: string) => Promise<unknown[]>;
|
||||
} = {
|
||||
findByLeagueId: async () => [],
|
||||
} as any;
|
||||
|
||||
const leagueMembershipRepository = {
|
||||
};
|
||||
|
||||
const leagueMembershipRepository: {
|
||||
getMembership: (
|
||||
leagueId: string,
|
||||
driverIdParam: string,
|
||||
) => Promise<{ leagueId: string; driverId: string; status: string } | null>;
|
||||
} = {
|
||||
getMembership: async (leagueId: string, driverIdParam: string) => {
|
||||
return (
|
||||
memberships.find(
|
||||
@@ -122,22 +150,28 @@ describe('GetDashboardOverviewUseCase', () => {
|
||||
) ?? null
|
||||
);
|
||||
},
|
||||
} as any;
|
||||
|
||||
const raceRegistrationRepository = {
|
||||
};
|
||||
|
||||
const raceRegistrationRepository: {
|
||||
isRegistered: (raceId: string, driverIdParam: string) => Promise<boolean>;
|
||||
} = {
|
||||
isRegistered: async (raceId: string, driverIdParam: string) => {
|
||||
if (driverIdParam !== driverId) return false;
|
||||
return registeredRaceIds.has(raceId);
|
||||
},
|
||||
} as any;
|
||||
|
||||
const feedRepository = {
|
||||
};
|
||||
|
||||
const feedRepository: {
|
||||
getFeedForDriver: (driverIdParam: string) => Promise<DashboardFeedItemSummaryViewModel[]>;
|
||||
} = {
|
||||
getFeedForDriver: async () => feedItems,
|
||||
} as any;
|
||||
|
||||
const socialRepository = {
|
||||
};
|
||||
|
||||
const socialRepository: {
|
||||
getFriends: (driverIdParam: string) => Promise<Array<{ id: string }>>;
|
||||
} = {
|
||||
getFriends: async () => friends,
|
||||
} as any;
|
||||
};
|
||||
|
||||
const imageService = createTestImageService();
|
||||
|
||||
@@ -250,7 +284,10 @@ describe('GetDashboardOverviewUseCase', () => {
|
||||
},
|
||||
];
|
||||
|
||||
const standingsByLeague = new Map<string, any[]>();
|
||||
const standingsByLeague = new Map<
|
||||
string,
|
||||
Array<{ leagueId: string; driverId: string; position: number; points: number }>
|
||||
>();
|
||||
standingsByLeague.set('league-A', [
|
||||
{ leagueId: 'league-A', driverId, position: 3, points: 50 },
|
||||
{ leagueId: 'league-A', driverId: 'other-1', position: 1, points: 80 },
|
||||
@@ -260,28 +297,43 @@ describe('GetDashboardOverviewUseCase', () => {
|
||||
{ leagueId: 'league-B', driverId: 'other-2', position: 2, points: 90 },
|
||||
]);
|
||||
|
||||
const driverRepository = {
|
||||
const driverRepository: {
|
||||
findById: (id: string) => Promise<{ id: string; name: string; country: string } | null>;
|
||||
} = {
|
||||
findById: async (id: string) => (id === driver.id ? driver : null),
|
||||
} as any;
|
||||
|
||||
const raceRepository = {
|
||||
};
|
||||
|
||||
const raceRepository: {
|
||||
findAll: () => Promise<typeof races>;
|
||||
} = {
|
||||
findAll: async () => races,
|
||||
} as any;
|
||||
|
||||
const resultRepository = {
|
||||
};
|
||||
|
||||
const resultRepository: {
|
||||
findAll: () => Promise<typeof results>;
|
||||
} = {
|
||||
findAll: async () => results,
|
||||
} as any;
|
||||
|
||||
const leagueRepository = {
|
||||
};
|
||||
|
||||
const leagueRepository: {
|
||||
findAll: () => Promise<typeof leagues>;
|
||||
} = {
|
||||
findAll: async () => leagues,
|
||||
} as any;
|
||||
|
||||
const standingRepository = {
|
||||
};
|
||||
|
||||
const standingRepository: {
|
||||
findByLeagueId: (leagueId: string) => Promise<Array<{ leagueId: string; driverId: string; position: number; points: number }>>;
|
||||
} = {
|
||||
findByLeagueId: async (leagueId: string) =>
|
||||
standingsByLeague.get(leagueId) ?? [],
|
||||
} as any;
|
||||
|
||||
const leagueMembershipRepository = {
|
||||
};
|
||||
|
||||
const leagueMembershipRepository: {
|
||||
getMembership: (
|
||||
leagueId: string,
|
||||
driverIdParam: string,
|
||||
) => Promise<{ leagueId: string; driverId: string; status: string } | null>;
|
||||
} = {
|
||||
getMembership: async (leagueId: string, driverIdParam: string) => {
|
||||
return (
|
||||
memberships.find(
|
||||
@@ -289,19 +341,25 @@ describe('GetDashboardOverviewUseCase', () => {
|
||||
) ?? null
|
||||
);
|
||||
},
|
||||
} as any;
|
||||
|
||||
const raceRegistrationRepository = {
|
||||
};
|
||||
|
||||
const raceRegistrationRepository: {
|
||||
isRegistered: (raceId: string, driverIdParam: string) => Promise<boolean>;
|
||||
} = {
|
||||
isRegistered: async () => false,
|
||||
} as any;
|
||||
|
||||
const feedRepository = {
|
||||
};
|
||||
|
||||
const feedRepository: {
|
||||
getFeedForDriver: (driverIdParam: string) => Promise<DashboardFeedItemSummaryViewModel[]>;
|
||||
} = {
|
||||
getFeedForDriver: async () => [],
|
||||
} as any;
|
||||
|
||||
const socialRepository = {
|
||||
};
|
||||
|
||||
const socialRepository: {
|
||||
getFriends: (driverIdParam: string) => Promise<Array<{ id: string }>>;
|
||||
} = {
|
||||
getFriends: async () => [],
|
||||
} as any;
|
||||
};
|
||||
|
||||
const imageService = createTestImageService();
|
||||
|
||||
@@ -372,41 +430,53 @@ describe('GetDashboardOverviewUseCase', () => {
|
||||
|
||||
const driver = { id: driverId, name: 'New Racer', country: 'FR' };
|
||||
|
||||
const driverRepository = {
|
||||
const driverRepository: {
|
||||
findById: (id: string) => Promise<{ id: string; name: string; country: string } | null>;
|
||||
} = {
|
||||
findById: async (id: string) => (id === driver.id ? driver : null),
|
||||
} as any;
|
||||
|
||||
const raceRepository = {
|
||||
};
|
||||
|
||||
const raceRepository: { findAll: () => Promise<never[]> } = {
|
||||
findAll: async () => [],
|
||||
} as any;
|
||||
|
||||
const resultRepository = {
|
||||
};
|
||||
|
||||
const resultRepository: { findAll: () => Promise<never[]> } = {
|
||||
findAll: async () => [],
|
||||
} as any;
|
||||
|
||||
const leagueRepository = {
|
||||
};
|
||||
|
||||
const leagueRepository: { findAll: () => Promise<never[]> } = {
|
||||
findAll: async () => [],
|
||||
} as any;
|
||||
|
||||
const standingRepository = {
|
||||
};
|
||||
|
||||
const standingRepository: {
|
||||
findByLeagueId: (leagueId: string) => Promise<never[]>;
|
||||
} = {
|
||||
findByLeagueId: async () => [],
|
||||
} as any;
|
||||
|
||||
const leagueMembershipRepository = {
|
||||
};
|
||||
|
||||
const leagueMembershipRepository: {
|
||||
getMembership: (leagueId: string, driverIdParam: string) => Promise<null>;
|
||||
} = {
|
||||
getMembership: async () => null,
|
||||
} as any;
|
||||
|
||||
const raceRegistrationRepository = {
|
||||
};
|
||||
|
||||
const raceRegistrationRepository: {
|
||||
isRegistered: (raceId: string, driverIdParam: string) => Promise<boolean>;
|
||||
} = {
|
||||
isRegistered: async () => false,
|
||||
} as any;
|
||||
|
||||
const feedRepository = {
|
||||
};
|
||||
|
||||
const feedRepository: {
|
||||
getFeedForDriver: (driverIdParam: string) => Promise<DashboardFeedItemSummaryViewModel[]>;
|
||||
} = {
|
||||
getFeedForDriver: async () => [],
|
||||
} as any;
|
||||
|
||||
const socialRepository = {
|
||||
};
|
||||
|
||||
const socialRepository: {
|
||||
getFriends: (driverIdParam: string) => Promise<Array<{ id: string }>>;
|
||||
} = {
|
||||
getFriends: async () => [],
|
||||
} as any;
|
||||
};
|
||||
|
||||
const imageService = createTestImageService();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user