48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { RiotClientService } from './riot.client.service';
|
|
import { RiotLeagueService } from './riot-league.service';
|
|
import type { RiotLeagueEntryDto, RiotResponseParser } from './riot.types';
|
|
|
|
describe('RiotLeagueService', () => {
|
|
it('accepts Riot league entries without optional leagueId', async () => {
|
|
const client = {
|
|
get: jest.fn(
|
|
async <T>(
|
|
_path: string,
|
|
_options: unknown,
|
|
parser?: RiotResponseParser<T>,
|
|
) =>
|
|
parser
|
|
? parser([
|
|
{
|
|
queueType: 'RANKED_SOLO_5x5',
|
|
tier: 'EMERALD',
|
|
rank: 'I',
|
|
puuid: 'puuid-1',
|
|
leaguePoints: 75,
|
|
wins: 160,
|
|
losses: 148,
|
|
},
|
|
])
|
|
: ([] as T),
|
|
),
|
|
} as unknown as RiotClientService;
|
|
const service = new RiotLeagueService(client);
|
|
|
|
const result = await service.getEntriesByPuuid('puuid-1', {
|
|
platform: 'kr',
|
|
});
|
|
|
|
expect(result).toEqual<RiotLeagueEntryDto[]>([
|
|
{
|
|
queueType: 'RANKED_SOLO_5x5',
|
|
tier: 'EMERALD',
|
|
rank: 'I',
|
|
puuid: 'puuid-1',
|
|
leaguePoints: 75,
|
|
wins: 160,
|
|
losses: 148,
|
|
},
|
|
]);
|
|
});
|
|
});
|