mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Add bosses and support for leagues.
This commit is contained in:
@@ -5,8 +5,6 @@ import {
|
||||
getStats,
|
||||
getStatsByGamemode,
|
||||
} from '../src/index';
|
||||
import { PlayerSkillRow, Player, Stats } from '../src/types';
|
||||
import axios, { AxiosError } from 'axios';
|
||||
|
||||
test('Parse CSV to json', () => {
|
||||
const csv = `40258,2063,218035714
|
||||
@@ -33,16 +31,58 @@ test('Parse CSV to json', () => {
|
||||
53099, 80, 2008229
|
||||
169127, 73, 1067670
|
||||
115543, 82, 2546048
|
||||
-1, -1
|
||||
-1, -1
|
||||
32875, 500
|
||||
-1, -1
|
||||
-1, -1
|
||||
-1, -1
|
||||
24817, 476
|
||||
212728, 1
|
||||
94827, 20
|
||||
59099, 74
|
||||
24642, 231
|
||||
5206, 99
|
||||
6293, 51`;
|
||||
6293, 51
|
||||
32875, 500
|
||||
374,2780
|
||||
934,3000
|
||||
1936,1452
|
||||
4919,23
|
||||
101,4038
|
||||
152,334
|
||||
6153,133
|
||||
4501,250
|
||||
6806,603
|
||||
1,17798
|
||||
9160,125
|
||||
1021,2802
|
||||
4295,1655
|
||||
959,2951
|
||||
10009,1
|
||||
1271,2407
|
||||
378,4669
|
||||
543,1567
|
||||
6003,94
|
||||
263,2897
|
||||
4000,1277
|
||||
41016,1477
|
||||
617,2391
|
||||
120,2981
|
||||
1,109
|
||||
26,323
|
||||
198,1101
|
||||
81,3404
|
||||
5027,61
|
||||
63,375
|
||||
2845,6
|
||||
6913,138
|
||||
3999,2000
|
||||
484,8
|
||||
957,47
|
||||
10987,223
|
||||
1923,272
|
||||
8484,1340
|
||||
599,1694
|
||||
-1,-1
|
||||
3810,4583`;
|
||||
|
||||
expect(parseStats(csv)).toStrictEqual({
|
||||
skills: {
|
||||
@@ -85,238 +125,272 @@ test('Parse CSV to json', () => {
|
||||
elite: { rank: 5206, score: 99 },
|
||||
master: { rank: 6293, score: 51 },
|
||||
},
|
||||
bosses: {
|
||||
abyssalsire: { rank: 374, score: 2780 },
|
||||
alchemicalhydra: { rank: 934, score: 3000 },
|
||||
barrowschests: { rank: 1936, score: 1452 },
|
||||
bryophyta: { rank: 4919, score: 23 },
|
||||
chambersofxeric: { rank: 101, score: 4038 },
|
||||
chambersofxericchallengemode: { rank: 152, score: 334 },
|
||||
chaoselemental: { rank: -1, score: -1 },
|
||||
chaosfanatic: { rank: -1, score: -1 },
|
||||
commanderzilyana: { rank: 6806, score: 603 },
|
||||
corporealbeast: { rank: 1, score: 17798 },
|
||||
crazyarchaeologist: { rank: 9160, score: 125 },
|
||||
dagannothprime: { rank: 1021, score: 2802 },
|
||||
dagannothrex: { rank: 4295, score: 1655 },
|
||||
dagannothsupreme: { rank: 959, score: 2951 },
|
||||
derangedarchaeologist: { rank: 10009, score: 1 },
|
||||
generalgraardor: { rank: 1271, score: 2407 },
|
||||
giantmole: { rank: 378, score: 4669 },
|
||||
grotesqueguardians: { rank: 543, score: 1567 },
|
||||
hespori: { rank: 6003, score: 94 },
|
||||
kalphitequeen: { rank: 263, score: 2897 },
|
||||
kingblackdragon: { rank: 4000, score: 1277 },
|
||||
kraken: { rank: 41016, score: 1477 },
|
||||
kreearra: { rank: 617, score: 2391 },
|
||||
kriltsutsaroth: { rank: 120, score: 2981 },
|
||||
mimic: { rank: 1, score: 109 },
|
||||
obor: { rank: 26, score: 323 },
|
||||
sarachnis: { rank: 198, score: 1101 },
|
||||
scorpia: { rank: 81, score: 3404 },
|
||||
skotizo: { rank: 5027, score: 61 },
|
||||
gauntlet: { rank: 63, score: 375 },
|
||||
corruptedgauntlet: { rank: 2845, score: 6 },
|
||||
theatreofblood: { rank: 6913, score: 138 },
|
||||
thermonuclearsmokedevil: { rank: 3999, score: 2000 },
|
||||
tzkalzuk: { rank: 484, score: 8 },
|
||||
tztokjad: { rank: 957, score: 47 },
|
||||
venenatis: { rank: 10987, score: 223 },
|
||||
vetion: { rank: 1923, score: 272 },
|
||||
vorkath: { rank: 8484, score: 1340 },
|
||||
wintertodt: { rank: 599, score: 1694 },
|
||||
zalcano: { rank: -1, score: -1 },
|
||||
zulrah: { rank: 3810, score: 4583 },
|
||||
callisto: { rank: -1, score: -1 },
|
||||
cerberus: { rank: -1, score: -1 },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
test('Get rsn format', async done => {
|
||||
const callback = (data: string) => {
|
||||
expect(data).toBe('Lynx Titan');
|
||||
done();
|
||||
};
|
||||
|
||||
getRSNFormat('lYnX tiTaN').then(callback);
|
||||
test('Get rsn format', async () => {
|
||||
jest.setTimeout(30000);
|
||||
const data = await getRSNFormat('lYnX tiTaN');
|
||||
expect(data).toBe('Lynx Titan');
|
||||
});
|
||||
|
||||
test('Get attack top page', async done => {
|
||||
const callback = (data: PlayerSkillRow[]) => {
|
||||
expect(data).toMatchObject([
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 1,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 2,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{ rsn: 'Drakon', rank: 3, level: 99, xp: 200000000, dead: false },
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 4,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 5,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 6,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 7,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 8,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 9,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 10,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 11,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 12,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 13,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 14,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 15,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 16,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 17,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 18,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 19,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 20,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 21,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 22,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 23,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 24,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 25,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
]);
|
||||
done();
|
||||
};
|
||||
|
||||
getSkillPage('attack').then(callback);
|
||||
test('Get attack top page', async () => {
|
||||
jest.setTimeout(30000);
|
||||
const data = await getSkillPage('attack');
|
||||
expect(data).toMatchObject([
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 1,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 2,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{ rsn: 'Drakon', rank: 3, level: 99, xp: 200000000, dead: false },
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 4,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 5,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 6,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 7,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 8,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 9,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 10,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 11,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 12,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 13,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 14,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 15,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 16,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 17,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 18,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 19,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 20,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 21,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 22,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 23,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 24,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
{
|
||||
rsn: expect.any(String),
|
||||
rank: 25,
|
||||
level: 99,
|
||||
xp: 200000000,
|
||||
dead: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
test('Get non-existant player', async done => {
|
||||
const callback = (err: AxiosError) => {
|
||||
test('Get non-existant player', async () => {
|
||||
jest.setTimeout(30000);
|
||||
getStats('fishy').catch(err => {
|
||||
if (err.response) {
|
||||
expect(err.response.status).toBe(404);
|
||||
}
|
||||
done();
|
||||
};
|
||||
|
||||
getStats('fishy').catch(callback);
|
||||
});
|
||||
});
|
||||
|
||||
test('Get stats by gamemode', async done => {
|
||||
const callback = (stats: Stats) => {
|
||||
expect(stats.skills).toStrictEqual({
|
||||
overall: { rank: 1, level: 2277, xp: 4600000000 },
|
||||
attack: { rank: 15, level: 99, xp: 200000000 },
|
||||
defence: { rank: 27, level: 99, xp: 200000000 },
|
||||
strength: { rank: 18, level: 99, xp: 200000000 },
|
||||
hitpoints: { rank: 7, level: 99, xp: 200000000 },
|
||||
ranged: { rank: 7, level: 99, xp: 200000000 },
|
||||
prayer: { rank: 11, level: 99, xp: 200000000 },
|
||||
magic: { rank: 32, level: 99, xp: 200000000 },
|
||||
cooking: { rank: 158, level: 99, xp: 200000000 },
|
||||
woodcutting: { rank: 15, level: 99, xp: 200000000 },
|
||||
fletching: { rank: 12, level: 99, xp: 200000000 },
|
||||
fishing: { rank: 9, level: 99, xp: 200000000 },
|
||||
firemaking: { rank: 49, level: 99, xp: 200000000 },
|
||||
crafting: { rank: 4, level: 99, xp: 200000000 },
|
||||
smithing: { rank: 3, level: 99, xp: 200000000 },
|
||||
mining: { rank: 25, level: 99, xp: 200000000 },
|
||||
herblore: { rank: 5, level: 99, xp: 200000000 },
|
||||
agility: { rank: 24, level: 99, xp: 200000000 },
|
||||
thieving: { rank: 12, level: 99, xp: 200000000 },
|
||||
slayer: { rank: 2, level: 99, xp: 200000000 },
|
||||
farming: { rank: 19, level: 99, xp: 200000000 },
|
||||
runecraft: { rank: 7, level: 99, xp: 200000000 },
|
||||
hunter: { rank: 4, level: 99, xp: 200000000 },
|
||||
construction: { rank: 4, level: 99, xp: 200000000 },
|
||||
});
|
||||
done();
|
||||
};
|
||||
|
||||
getStatsByGamemode('Lynx Titan').then(callback);
|
||||
test('Get stats by gamemode', async () => {
|
||||
jest.setTimeout(30000);
|
||||
const { skills } = await getStatsByGamemode('Lynx Titan');
|
||||
expect(skills).toMatchObject({
|
||||
overall: { rank: expect.any(Number), level: 2277, xp: 4600000000 },
|
||||
attack: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
defence: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
strength: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
hitpoints: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
ranged: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
prayer: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
magic: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
cooking: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
woodcutting: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
fletching: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
fishing: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
firemaking: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
crafting: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
smithing: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
mining: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
herblore: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
agility: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
thieving: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
slayer: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
farming: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
runecraft: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
hunter: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
construction: { rank: expect.any(Number), level: 99, xp: 200000000 },
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user