integration tests

This commit is contained in:
2026-01-23 14:51:33 +01:00
parent 34eae53184
commit 95276df5af
18 changed files with 2875 additions and 3692 deletions

View File

@@ -5,52 +5,86 @@
import type { Transaction, Wallet } from '@core/payments/domain/entities/Wallet';
import type { WalletRepository, TransactionRepository } from '@core/payments/domain/repositories/WalletRepository';
import type { Logger } from '@core/shared/domain/Logger';
import type { LeagueWalletRepository } from '@core/racing/domain/repositories/LeagueWalletRepository';
const wallets: Map<string, Wallet> = new Map();
const transactions: Map<string, Transaction> = new Map();
const wallets: Map<string, any> = new Map();
const transactions: Map<string, any> = new Map();
export class InMemoryWalletRepository implements WalletRepository {
export class InMemoryWalletRepository implements WalletRepository, LeagueWalletRepository {
constructor(private readonly logger: Logger) {}
async findById(id: string): Promise<Wallet | null> {
async findById(id: string): Promise<any | null> {
this.logger.debug('[InMemoryWalletRepository] findById', { id });
return wallets.get(id) || null;
}
async findByLeagueId(leagueId: string): Promise<Wallet | null> {
async findByLeagueId(leagueId: string): Promise<any | null> {
this.logger.debug('[InMemoryWalletRepository] findByLeagueId', { leagueId });
return Array.from(wallets.values()).find(w => w.leagueId === leagueId) || null;
return Array.from(wallets.values()).find(w => w.leagueId.toString() === leagueId) || null;
}
async create(wallet: Wallet): Promise<Wallet> {
async create(wallet: any): Promise<any> {
this.logger.debug('[InMemoryWalletRepository] create', { wallet });
wallets.set(wallet.id, wallet);
wallets.set(wallet.id.toString(), wallet);
return wallet;
}
async update(wallet: Wallet): Promise<Wallet> {
async update(wallet: any): Promise<any> {
this.logger.debug('[InMemoryWalletRepository] update', { wallet });
wallets.set(wallet.id, wallet);
wallets.set(wallet.id.toString(), wallet);
return wallet;
}
async delete(id: string): Promise<void> {
wallets.delete(id);
}
async exists(id: string): Promise<boolean> {
return wallets.has(id);
}
clear(): void {
wallets.clear();
}
}
export class InMemoryTransactionRepository implements TransactionRepository {
constructor(private readonly logger: Logger) {}
async findById(id: string): Promise<Transaction | null> {
async findById(id: string): Promise<any | null> {
this.logger.debug('[InMemoryTransactionRepository] findById', { id });
return transactions.get(id) || null;
}
async findByWalletId(walletId: string): Promise<Transaction[]> {
async findByWalletId(walletId: string): Promise<any[]> {
this.logger.debug('[InMemoryTransactionRepository] findByWalletId', { walletId });
return Array.from(transactions.values()).filter(t => t.walletId === walletId);
return Array.from(transactions.values()).filter(t => t.walletId.toString() === walletId);
}
async create(transaction: Transaction): Promise<Transaction> {
async create(transaction: any): Promise<any> {
this.logger.debug('[InMemoryTransactionRepository] create', { transaction });
transactions.set(transaction.id, transaction);
transactions.set(transaction.id.toString(), transaction);
return transaction;
}
}
async update(transaction: any): Promise<any> {
transactions.set(transaction.id.toString(), transaction);
return transaction;
}
async delete(id: string): Promise<void> {
transactions.delete(id);
}
async exists(id: string): Promise<boolean> {
return transactions.has(id);
}
findByType(type: any): Promise<any[]> {
return Promise.resolve(Array.from(transactions.values()).filter(t => t.type === type));
}
clear(): void {
transactions.clear();
}
}