Skip to content

Commit f59152f

Browse files
committed
✅ Update tests to check throwned errors
1 parent f7c921c commit f59152f

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

tests/api/getCoverByBookId.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ describe('GetCoverBookById', () => {
2828
expect(coverByBookId).to.satisfy((cover: File) => !isNil(cover));
2929
});
3030

31-
it('should return axios error', async () => {
32-
const coverByBookId = await getCoverByBookIdApi.getCoverByBookId(Number.POSITIVE_INFINITY);
31+
it('should return undefined error', async () => {
32+
const coverByBookId = await getCoverByBookIdApi
33+
.getCoverByBookId(Number.POSITIVE_INFINITY);
3334

34-
expect(axios.isAxiosError(coverByBookId)).to.be.equal(true);
35+
expect(isNil(coverByBookId)).to.be.equal(true);
3536
});
3637
});
3738
});

tests/flibustaApiHelper.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,10 @@ describe('FlibustaAPIHelper', () => {
5959

6060
it('should return axios error when flibusta html page is wrong', async () => {
6161
const url = 'booksed';
62-
const flibustaHTMLPage = await flibustaApiHelper.getFlibustaHTMLPage(url);
63-
64-
if (isNil(flibustaHTMLPage)) {
65-
return;
66-
}
6762

68-
expect(axios.isAxiosError(flibustaHTMLPage)).to.be.equal(true);
63+
await flibustaApiHelper.getFlibustaHTMLPage(url).catch((error) => {
64+
expect(axios.isAxiosError(error)).to.be.equal(true);
65+
});
6966
});
7067
});
7168

tests/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,9 +394,9 @@ describe('FlibustaAPI', () => {
394394
});
395395

396396
it('should return axios error', async () => {
397-
const coverByBookId = await flibustaApi.getCoverByBookId(Number.POSITIVE_INFINITY);
398-
399-
expect(axios.isAxiosError(coverByBookId)).to.be.equal(true);
397+
await flibustaApi.getCoverByBookId(Number.POSITIVE_INFINITY).catch((error) => {
398+
expect(axios.isAxiosError(error)).to.be.equal(true);
399+
});
400400
});
401401
});
402402
});

0 commit comments

Comments
 (0)