Throw error for unknown hiscores CSV format

This commit is contained in:
molo-pl
2022-01-04 23:03:52 +01:00
parent 8737b50a82
commit f98cf8aaaa
3 changed files with 20 additions and 2 deletions

View File

@@ -11,7 +11,8 @@ import {
getPlayerTableURL,
getSkillPageURL,
getStatsURL,
BOSSES
BOSSES,
INVALID_FORMAT_ERROR
} from '../src/index';
const B0ATY_NAME = 'B0ATY';
@@ -232,6 +233,16 @@ test('Parse CSV to json', () => {
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', () => {
it('gets a name with a space', async () => {
const data = await getRSNFormat(LYNX_TITAN_SPACE_NAME);