Skip to content
This repository was archived by the owner on Sep 10, 2023. It is now read-only.

Commit

Permalink
fix: node-fetch typings
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Oct 17, 2021
1 parent 4701069 commit c368107
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 23 deletions.
50 changes: 32 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"dependencies": {
"fast-xml-parser": "^3.20.3",
"node-fetch": "^2.6.5",
"tslib": "^2.3.1",
"yargs": "^17.2.1"
},
"devDependencies": {
Expand All @@ -49,7 +50,7 @@
"@babel/preset-typescript": "^7.15.0",
"@types/jest": "^27.0.2",
"@types/node": "^16.11.1",
"@types/node-fetch": "^3.0.3",
"@types/node-fetch": "^2.5.12",
"@types/yargs": "^17.0.4",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
Expand Down
12 changes: 8 additions & 4 deletions test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { search } from '../src/index';
test('should throw on invalid site', async () => {
try {
await search('asd123');
} catch (error) {
} catch (e) {
const error = e as Error;
expect(error).toBeInstanceOf(Error);
expect(error.message).toBe('This site is not supported.');
}
Expand All @@ -14,7 +15,8 @@ test('should throw on non-string', async () => {
try {
// @ts-ignore
await search(123);
} catch (error) {
} catch (e) {
const error = e as Error;
expect(error).toBeInstanceOf(Error);
expect(error.message).toBe('This site is not supported.');
}
Expand All @@ -24,7 +26,8 @@ test('should throw on tags not being an array', async () => {
try {
// @ts-ignore
await search('danbooru', { tags: 'test' });
} catch (error) {
} catch (e) {
const error = e as Error;
expect(error).toBeInstanceOf(Error);
expect(error.message).toBe('Tags have to be an array.');
}
Expand All @@ -34,7 +37,8 @@ test('should throw on limit not being a number', async () => {
try {
// @ts-ignore
await search('danbooru', { limit: {} });
} catch (error) {
} catch (e) {
const error = e as Error;
expect(error).toBeInstanceOf(Error);
expect(error.message).toBe('Limit has to be a number.');
}
Expand Down

0 comments on commit c368107

Please sign in to comment.