From d94a3877b0ad48385d31eb2cce288ab279093a39 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 15 Jun 2019 15:23:44 -0400 Subject: [PATCH] Add test for non-existant player --- __tests__/hiscores.test.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/__tests__/hiscores.test.ts b/__tests__/hiscores.test.ts index 27c89c4..1ef28b1 100644 --- a/__tests__/hiscores.test.ts +++ b/__tests__/hiscores.test.ts @@ -1,5 +1,6 @@ -import { parseStats, getRSNFormat, getSkillPage } from '../src/index'; -import { PlayerSkillRow } from '../src/types'; +import { parseStats, getRSNFormat, getSkillPage, getStats } from '../src/index'; +import { PlayerSkillRow, Player } from '../src/types'; +import axios, { AxiosError } from 'axios'; test('Parse CSV to json', () => { const csv = `40258,2063,218035714 @@ -208,3 +209,14 @@ test('Get attack top page', async done => { getSkillPage('attack').then(callback); }); + +test('Get non-existant player', async done => { + const callback = (err: AxiosError) => { + if (err.response) { + expect(err.response.status).toBe(404); + } + done(); + }; + + getStats('fishy').catch(callback); +});