fix core tests
This commit is contained in:
@@ -166,12 +166,29 @@ describe('AcceptSponsorshipRequestUseCase', () => {
|
||||
balance: 1000,
|
||||
}),
|
||||
);
|
||||
expect(mockLeagueWalletRepo.update).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
id: 'league1',
|
||||
balance: expect.objectContaining({ amount: 1400 }),
|
||||
}),
|
||||
);
|
||||
expect(mockLeagueWalletRepo.update).toHaveBeenCalledTimes(1);
|
||||
const updatedLeagueWallet = (mockLeagueWalletRepo.update as Mock).mock.calls[0]?.[0] as LeagueWallet;
|
||||
|
||||
type ToStringable = { toString(): string };
|
||||
const asString = (value: unknown): string => {
|
||||
if (typeof value === 'string') return value;
|
||||
if (
|
||||
value &&
|
||||
typeof value === 'object' &&
|
||||
'toString' in value &&
|
||||
typeof (value as ToStringable).toString === 'function'
|
||||
) {
|
||||
return (value as ToStringable).toString();
|
||||
}
|
||||
return String(value);
|
||||
};
|
||||
|
||||
const updatedLeagueWalletId = (updatedLeagueWallet as unknown as { id: unknown }).id;
|
||||
const updatedLeagueWalletBalanceAmount = (updatedLeagueWallet as unknown as { balance: { amount: number } })
|
||||
.balance.amount;
|
||||
|
||||
expect(asString(updatedLeagueWalletId)).toBe('league1');
|
||||
expect(updatedLeagueWalletBalanceAmount).toBe(1400);
|
||||
|
||||
expect(output.present).toHaveBeenCalledWith({
|
||||
requestId: 'req1',
|
||||
|
||||
Reference in New Issue
Block a user