mirror of
https://github.com/maxswa/osrs-json-hiscores.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
5 Commits
add-nex
...
fix-tests-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44dea6b35c | ||
|
|
0bf491638c | ||
|
|
febca534b0 | ||
|
|
8daee5c39b | ||
|
|
f98cf8aaaa |
@@ -11,7 +11,8 @@ import {
|
|||||||
getPlayerTableURL,
|
getPlayerTableURL,
|
||||||
getSkillPageURL,
|
getSkillPageURL,
|
||||||
getStatsURL,
|
getStatsURL,
|
||||||
BOSSES
|
BOSSES,
|
||||||
|
INVALID_FORMAT_ERROR
|
||||||
} from '../src/index';
|
} from '../src/index';
|
||||||
|
|
||||||
const B0ATY_NAME = 'B0ATY';
|
const B0ATY_NAME = 'B0ATY';
|
||||||
@@ -234,6 +235,16 @@ test('Parse CSV to json', () => {
|
|||||||
expect(parseStats(csv)).toStrictEqual(expectedOutput);
|
expect(parseStats(csv)).toStrictEqual(expectedOutput);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parse CSV with unknown activity', () => {
|
||||||
|
const statsWithUnknownActivity = lynxTitanStats + `
|
||||||
|
-1,-1`;
|
||||||
|
expect(() => parseStats(statsWithUnknownActivity)).toThrow(INVALID_FORMAT_ERROR);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Parse invalid CSV', () => {
|
||||||
|
expect(() => parseStats('invalid')).toThrow(INVALID_FORMAT_ERROR);
|
||||||
|
});
|
||||||
|
|
||||||
describe('Get name format', () => {
|
describe('Get name format', () => {
|
||||||
it('gets a name with a space', async () => {
|
it('gets a name with a space', async () => {
|
||||||
const data = await getRSNFormat(LYNX_TITAN_SPACE_NAME);
|
const data = await getRSNFormat(LYNX_TITAN_SPACE_NAME);
|
||||||
|
|||||||
@@ -80,4 +80,5 @@
|
|||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
|
-1,-1
|
||||||
-1,-1
|
-1,-1
|
||||||
|
Can't render this file because it has a wrong number of fields in line 25.
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "osrs-json-hiscores",
|
"name": "osrs-json-hiscores",
|
||||||
"version": "2.6.0",
|
"version": "2.7.0",
|
||||||
"description": "The Old School Runescape API wrapper that does more!",
|
"description": "The Old School Runescape API wrapper that does more!",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ import {
|
|||||||
rsnFromElement,
|
rsnFromElement,
|
||||||
getActivityPageURL,
|
getActivityPageURL,
|
||||||
httpGet,
|
httpGet,
|
||||||
BOSSES
|
BOSSES,
|
||||||
|
INVALID_FORMAT_ERROR
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,6 +75,10 @@ export function parseStats(csv: string): Stats {
|
|||||||
.filter((entry) => !!entry)
|
.filter((entry) => !!entry)
|
||||||
.map((stat) => stat.split(','));
|
.map((stat) => stat.split(','));
|
||||||
|
|
||||||
|
if (splitCSV.length !== SKILLS.length + BH_MODES.length + CLUES.length + BOSSES.length + 3) {
|
||||||
|
throw Error(INVALID_FORMAT_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
const skillObjects: Skill[] = splitCSV
|
const skillObjects: Skill[] = splitCSV
|
||||||
.filter((stat) => stat.length === 3)
|
.filter((stat) => stat.length === 3)
|
||||||
.map((stat) => {
|
.map((stat) => {
|
||||||
|
|||||||
@@ -247,3 +247,5 @@ export const FORMATTED_BH_NAMES: FormattedBHNames = {
|
|||||||
export const FORMATTED_LMS = 'Last Man Standing';
|
export const FORMATTED_LMS = 'Last Man Standing';
|
||||||
export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
|
export const FORMATTED_SOUL_WARS = 'Soul Wars Zeal';
|
||||||
export const FORMATTED_LEAGUE_POINTS = 'League Points';
|
export const FORMATTED_LEAGUE_POINTS = 'League Points';
|
||||||
|
|
||||||
|
export const INVALID_FORMAT_ERROR = 'Invalid hiscores format';
|
||||||
|
|||||||
Reference in New Issue
Block a user