This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

semble / src / modules / cards / tests / utils / FakeProfileService.ts
1.3 kB 50 lines
1import { 2 IProfileService, 3 UserProfile, 4} from '../../domain/services/IProfileService'; 5import { Result, ok, err } from '../../../../shared/core/Result'; 6 7export class FakeProfileService implements IProfileService { 8 private profiles: Map<string, UserProfile> = new Map(); 9 private shouldFail: boolean = false; 10 11 async getProfile(userId: string): Promise<Result<UserProfile>> { 12 if (this.shouldFail) { 13 return err(new Error('Simulated profile service failure')); 14 } 15 16 const profile = this.profiles.get(userId); 17 if (!profile) { 18 return err(new Error(`Profile not found for user: ${userId}`)); 19 } 20 21 return ok(profile); 22 } 23 24 async invalidateCounts(userId: string): Promise<void> { 25 // No-op for fake implementation 26 // In real implementation, this would invalidate the cache 27 } 28 29 // Test helper methods 30 addProfile(profile: UserProfile): void { 31 this.profiles.set(profile.id, profile); 32 } 33 34 setShouldFail(shouldFail: boolean): void { 35 this.shouldFail = shouldFail; 36 } 37 38 clear(): void { 39 this.profiles.clear(); 40 this.shouldFail = false; 41 } 42 43 getStoredProfile(userId: string): UserProfile | undefined { 44 return this.profiles.get(userId); 45 } 46 47 getAllProfiles(): UserProfile[] { 48 return Array.from(this.profiles.values()); 49 } 50}