website refactor
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* Tests for GetUserRatingsSummaryQuery
|
||||
*/
|
||||
|
||||
import { describe, expect, it, beforeEach, vi } from 'vitest';
|
||||
import { describe, expect, it, beforeEach, vi, type Mock } from 'vitest';
|
||||
import { GetUserRatingsSummaryQuery, GetUserRatingsSummaryQueryHandler } from './GetUserRatingsSummaryQuery';
|
||||
import { UserRating } from '../../domain/value-objects/UserRating';
|
||||
import { ExternalGameRatingProfile } from '../../domain/entities/ExternalGameRatingProfile';
|
||||
@@ -13,11 +13,16 @@ import { RatingEvent } from '../../domain/entities/RatingEvent';
|
||||
import { RatingEventId } from '../../domain/value-objects/RatingEventId';
|
||||
import { RatingDimensionKey } from '../../domain/value-objects/RatingDimensionKey';
|
||||
import { RatingDelta } from '../../domain/value-objects/RatingDelta';
|
||||
import { UserRatingRepository } from '../../domain/repositories/UserRatingRepository';
|
||||
import { ExternalGameRatingRepository } from '../../domain/repositories/ExternalGameRatingRepository';
|
||||
import { RatingEventRepository } from '../../domain/repositories/RatingEventRepository';
|
||||
|
||||
import { UserId } from '../../domain/value-objects/UserId';
|
||||
|
||||
describe('GetUserRatingsSummaryQuery', () => {
|
||||
let mockUserRatingRepo: any;
|
||||
let mockExternalRatingRepo: any;
|
||||
let mockRatingEventRepo: any;
|
||||
let mockUserRatingRepo: { findByUserId: Mock };
|
||||
let mockExternalRatingRepo: { findByUserId: Mock };
|
||||
let mockRatingEventRepo: { getAllByUserId: Mock };
|
||||
let handler: GetUserRatingsSummaryQueryHandler;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -32,9 +37,9 @@ describe('GetUserRatingsSummaryQuery', () => {
|
||||
};
|
||||
|
||||
handler = new GetUserRatingsSummaryQueryHandler(
|
||||
mockUserRatingRepo,
|
||||
mockExternalRatingRepo,
|
||||
mockRatingEventRepo
|
||||
mockUserRatingRepo as unknown as UserRatingRepository,
|
||||
mockExternalRatingRepo as unknown as ExternalGameRatingRepository,
|
||||
mockRatingEventRepo as unknown as RatingEventRepository
|
||||
);
|
||||
});
|
||||
|
||||
@@ -49,7 +54,7 @@ describe('GetUserRatingsSummaryQuery', () => {
|
||||
// Mock external ratings
|
||||
const gameKey = GameKey.create('iracing');
|
||||
const profile = ExternalGameRatingProfile.create({
|
||||
userId: { toString: () => userId } as any,
|
||||
userId: UserId.fromString(userId),
|
||||
gameKey,
|
||||
ratings: new Map([
|
||||
['iRating', ExternalRating.create(gameKey, 'iRating', 2200)],
|
||||
@@ -109,7 +114,7 @@ describe('GetUserRatingsSummaryQuery', () => {
|
||||
|
||||
// Multiple game profiles
|
||||
const iracingProfile = ExternalGameRatingProfile.create({
|
||||
userId: { toString: () => userId } as any,
|
||||
userId: UserId.fromString(userId),
|
||||
gameKey: GameKey.create('iracing'),
|
||||
ratings: new Map([
|
||||
['iRating', ExternalRating.create(GameKey.create('iracing'), 'iRating', 2200)],
|
||||
@@ -118,7 +123,7 @@ describe('GetUserRatingsSummaryQuery', () => {
|
||||
});
|
||||
|
||||
const assettoProfile = ExternalGameRatingProfile.create({
|
||||
userId: { toString: () => userId } as any,
|
||||
userId: UserId.fromString(userId),
|
||||
gameKey: GameKey.create('assetto'),
|
||||
ratings: new Map([
|
||||
['rating', ExternalRating.create(GameKey.create('assetto'), 'rating', 85)],
|
||||
|
||||
Reference in New Issue
Block a user