Add apex league Riot client methods

This commit is contained in:
dahyeon committed 2026-07-03 00:48:59 -07:00
1 parent 8668234065
commit 67b4032ff0
2 files changed
+159

No files matched your search

@@ -178,6 +178,81 @@ describe('RiotApiClient', () => {
]);
});
it('fetches apex League-V4 lists by queue without legacy summoner ids', async () => {
const fetchMock = createFetchMock().mockResolvedValue(
jsonResponse({
tier: 'CHALLENGER',
queue: 'RANKED_SOLO_5x5',
entries: [
{
puuid: 'seed-puuid-1',
leaguePoints: 1200,
rank: 'I',
wins: 300,
losses: 210,
veteran: true,
inactive: false,
freshBlood: false,
hotStreak: true,
},
],
}),
);
const { client, waitForSlot } = createClient(fetchMock);
await expect(
client.getChallengerLeagueByQueue('RANKED_SOLO_5x5', 'kr'),
).resolves.toEqual({
tier: 'CHALLENGER',
queueType: 'RANKED_SOLO_5x5',
entries: [
{
puuid: 'seed-puuid-1',
tier: 'CHALLENGER',
queueType: 'RANKED_SOLO_5x5',
rank: 'I',
leaguePoints: 1200,
wins: 300,
losses: 210,
veteran: true,
inactive: false,
freshBlood: false,
hotStreak: true,
},
],
});
expect(waitForSlot).toHaveBeenCalledWith('kr');
expect(fetchMock).toHaveBeenCalledWith(
'https://kr.api.riotgames.com/lol/league/v4/challengerleagues/by-queue/RANKED_SOLO_5x5',
expect.any(Object),
);
});
it('rejects apex League-V4 list entries without puuid', async () => {
const fetchMock = createFetchMock().mockResolvedValue(
jsonResponse({
tier: 'MASTER',
queue: 'RANKED_SOLO_5x5',
entries: [
{
leaguePoints: 200,
rank: 'I',
wins: 120,
losses: 100,
},
],
}),
);
const { client } = createClient(fetchMock);
await expect(
client.getMasterLeagueByQueue('RANKED_SOLO_5x5', 'kr'),
).rejects.toThrow(
'Riot apex league entry response was missing string field "puuid".',
);
});
it('honors Retry-After for 429 responses and retries', async () => {
const sleep = jest
.fn<Promise<void>, [number]>()