-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from quran/dev
fix: don't mutate mergeApiOptions params so that fetchFn works
- Loading branch information
Showing
3 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import fetch from 'cross-fetch'; | ||
import { quran } from '../src'; | ||
|
||
describe('Custom fetcher', () => { | ||
it('should fail with no fetch', () => { | ||
// @ts-expect-error - we are testing this | ||
globalThis.fetch = undefined; | ||
|
||
expect(() => quran.v4.chapters.findAll()).rejects.toThrowError( | ||
/global fetch/ | ||
); | ||
}); | ||
|
||
it('should not fail if you pass a fetchFn', () => { | ||
// @ts-expect-error - we are testing this | ||
globalThis.fetch = undefined; | ||
|
||
expect( | ||
quran.v4.chapters.findById('1', { | ||
fetchFn: (url) => { | ||
return fetch(url).then((res) => res.json()); | ||
}, | ||
}) | ||
).resolves.not.toThrow(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f866919
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
api – ./docs
quranjs.vercel.app
quranjs.com
www.quranjs.com
api-quranjs.vercel.app
api-git-master-quranjs.vercel.app