110 lines
2.8 KiB
TypeScript
110 lines
2.8 KiB
TypeScript
import { RiotClientService } from './riot.client.service';
|
|
import { RiotMatchService } from './riot-match.service';
|
|
import type { RiotResponseParser } from './riot.types';
|
|
|
|
function createMatchPayload() {
|
|
const participant = {
|
|
assists: 7,
|
|
champExperience: 12000,
|
|
champLevel: 16,
|
|
championId: 103,
|
|
championName: 'Ahri',
|
|
deaths: 2,
|
|
goldEarned: 12000,
|
|
goldSpent: 11000,
|
|
individualPosition: '',
|
|
item0: 0,
|
|
item1: 0,
|
|
item2: 0,
|
|
item3: 0,
|
|
item4: 0,
|
|
item5: 0,
|
|
item6: 0,
|
|
kills: 8,
|
|
neutralMinionsKilled: 12,
|
|
participantId: 1,
|
|
perks: {
|
|
statPerks: { defense: 0, flex: 0, offense: 0 },
|
|
styles: [],
|
|
},
|
|
puuid: 'puuid-1',
|
|
riotIdGameName: '테스터',
|
|
riotIdTagLine: 'KR1',
|
|
summoner1Id: 4,
|
|
summoner2Id: 14,
|
|
summonerId: 'summoner-id-1',
|
|
summonerLevel: 100,
|
|
summonerName: '',
|
|
teamId: 100,
|
|
teamPosition: '',
|
|
timePlayed: 1800,
|
|
totalDamageDealtToChampions: 22000,
|
|
totalDamageTaken: 11000,
|
|
totalMinionsKilled: 180,
|
|
visionScore: 20,
|
|
wardsKilled: 2,
|
|
wardsPlaced: 10,
|
|
win: true,
|
|
};
|
|
|
|
return {
|
|
metadata: {
|
|
dataVersion: '2',
|
|
matchId: 'KR_8188913502',
|
|
participants: ['puuid-1'],
|
|
},
|
|
info: {
|
|
gameCreation: 1777000000000,
|
|
gameDuration: 1800,
|
|
gameEndTimestamp: 1777001800000,
|
|
gameId: 8188913502,
|
|
gameMode: 'CLASSIC',
|
|
gameName: 'teambuilder-match-8188913502',
|
|
gameStartTimestamp: 1777000000000,
|
|
gameType: 'MATCHED_GAME',
|
|
gameVersion: '15.8.1',
|
|
mapId: 11,
|
|
participants: [participant],
|
|
platformId: 'KR',
|
|
queueId: 420,
|
|
teams: [
|
|
{
|
|
bans: [],
|
|
objectives: {
|
|
baron: { first: false, kills: 0 },
|
|
champion: { first: true, kills: 25 },
|
|
dragon: { first: true, kills: 3 },
|
|
inhibitor: { first: false, kills: 1 },
|
|
riftHerald: { first: true, kills: 1 },
|
|
tower: { first: true, kills: 8 },
|
|
},
|
|
teamId: 100,
|
|
win: true,
|
|
},
|
|
],
|
|
},
|
|
};
|
|
}
|
|
|
|
describe('RiotMatchService', () => {
|
|
it('accepts empty Riot display fields in match participants', async () => {
|
|
const payload = createMatchPayload();
|
|
const riotClientService = {
|
|
get: jest.fn(
|
|
async <T>(
|
|
_path: string,
|
|
_options: unknown,
|
|
parser?: RiotResponseParser<T>,
|
|
) => (parser ? parser(payload) : (payload as T)),
|
|
),
|
|
} as unknown as RiotClientService;
|
|
const service = new RiotMatchService(riotClientService);
|
|
|
|
const match = await service.getMatch('KR_8188913502', { region: 'asia' });
|
|
|
|
expect(match.info.participants[0].summonerName).toBe('');
|
|
expect(match.info.participants[0].teamPosition).toBe('');
|
|
expect(match.info.participants[0].individualPosition).toBe('');
|
|
});
|
|
});
|