feat: add item tooltips to match history
This commit is contained in:
1 parent
38c2d1f1b4
commit
68afaf0cb8
8 files changed
+477
-49
No files matched your search
@@ -0,0 +1,102 @@
|
||||
import { RedisService } from '../global/redis/redis.service';
|
||||
import { RiotDdragonService } from './riot-ddragon.service';
|
||||
|
||||
function jsonResponse(payload: unknown): Response {
|
||||
return {
|
||||
ok: true,
|
||||
json: jest.fn().mockResolvedValue(payload),
|
||||
} as unknown as Response;
|
||||
}
|
||||
|
||||
function makeRedisService() {
|
||||
return {
|
||||
getJson: jest.fn().mockResolvedValue(null),
|
||||
setJson: jest.fn().mockResolvedValue(undefined),
|
||||
} as unknown as jest.Mocked<RedisService>;
|
||||
}
|
||||
|
||||
describe('RiotDdragonService', () => {
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('includes localized item metadata in the manifest', async () => {
|
||||
const fetchMock = jest.fn(async (url: string) => {
|
||||
if (url.endsWith('/api/versions.json')) {
|
||||
return jsonResponse(['15.24.1']);
|
||||
}
|
||||
if (url.endsWith('/champion.json')) {
|
||||
return jsonResponse({
|
||||
data: {
|
||||
Aatrox: { key: '266', id: 'Aatrox', name: '아트록스' },
|
||||
},
|
||||
});
|
||||
}
|
||||
if (url.endsWith('/summoner.json')) {
|
||||
return jsonResponse({
|
||||
data: {
|
||||
SummonerFlash: { key: '4', id: 'SummonerFlash', name: '점멸' },
|
||||
},
|
||||
});
|
||||
}
|
||||
if (url.endsWith('/runesReforged.json')) {
|
||||
return jsonResponse([]);
|
||||
}
|
||||
if (url.endsWith('/item.json')) {
|
||||
return jsonResponse({
|
||||
data: {
|
||||
'1055': {
|
||||
name: '도란의 검',
|
||||
description:
|
||||
'<mainText><stats>공격력 <attention>10</attention></stats></mainText>',
|
||||
plaintext: '공격력과 체력을 올려줍니다.',
|
||||
gold: {
|
||||
base: 450,
|
||||
total: 450,
|
||||
sell: 180,
|
||||
purchasable: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
throw new Error(`Unexpected URL: ${url}`);
|
||||
});
|
||||
jest.spyOn(global, 'fetch').mockImplementation(fetchMock as typeof fetch);
|
||||
|
||||
const redis = makeRedisService();
|
||||
const service = new RiotDdragonService(redis);
|
||||
|
||||
await expect(service.getManifest('ko_KR')).resolves.toMatchObject({
|
||||
version: '15.24.1',
|
||||
locale: 'ko_KR',
|
||||
items: {
|
||||
'1055': {
|
||||
name: '도란의 검',
|
||||
description:
|
||||
'<mainText><stats>공격력 <attention>10</attention></stats></mainText>',
|
||||
plaintext: '공격력과 체력을 올려줍니다.',
|
||||
gold: {
|
||||
base: 450,
|
||||
total: 450,
|
||||
sell: 180,
|
||||
purchasable: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining('/15.24.1/data/ko_KR/item.json'),
|
||||
expect.any(Object),
|
||||
);
|
||||
expect(redis.setJson).toHaveBeenCalledWith(
|
||||
'ddragon:manifest:v4:ko_KR',
|
||||
expect.objectContaining({
|
||||
items: expect.objectContaining({
|
||||
'1055': expect.objectContaining({ name: '도란의 검' }),
|
||||
}),
|
||||
}),
|
||||
86_400,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user