diff --git a/src/apis/quran.test.ts b/src/apis/quran.test.ts new file mode 100644 index 0000000..23fa165 --- /dev/null +++ b/src/apis/quran.test.ts @@ -0,0 +1,62 @@ +import quran from "./quran"; + +describe("Testing the Quran APIs", () => { + + beforeEach(() => jest.clearAllMocks()); + + it("Shoud fetch Indo Pak Script of Ayah", async () => { + const res: any = await quran.getIndoPakScriptOfAyah(); + expect(res).toHaveProperty('verses'); + expect(res.meta.filters).toBeDefined(); + }); + + it("Should fetch Tajweed Script of Ayah", async () => { + const res: any = await quran.getUthmaniTajweedScriptOfAyah({ page_number: "1" }); + expect(res).toHaveProperty('meta'); + expect(res).toHaveProperty('verses'); + }); + + + it("Should fetch Uthmani script of ayah", async () => { + const res: any = await quran.getUthmaniScriptOfAyah({ page_number: "1" }); + expect(res).toHaveProperty('verses'); + expect(res).toHaveProperty('meta'); + }); + + it("Should fetch simple script of ayah", async () => { + const res: any = await quran.getUthmaniSimpleScriptOfAyah({ page_number: "1" }); + expect(res).toHaveProperty('verses'); + expect(res).toHaveProperty('meta'); + }); + + it("Should fetch simple text of ayah", async () => { + const res: any = await quran.getImlaeiSimpleTextOfAyah({ page_number: "1" }); + expect(res).toHaveProperty('verses'); + expect(res).toHaveProperty('meta'); + }); + + it("Should fetch a single translation", async () => { + const res: any = await quran.getASingleTranslation('85', { page_number: '1' }); + expect(res).toHaveProperty('translations'); + expect(res).toHaveProperty('meta'); + }); + + it("Should fetch a single tafsir", async () => { + const res: any = await quran.getSingleTafsir('381', { page_number: '1' }); + expect(res).toHaveProperty('tafsirs'); + expect(res).toHaveProperty('meta'); + }); + + it("Should fetch glyph codes of ayah v1", async () => { + const res: any = await quran.getGlyphCodesOfAyahV1({ page_number: '1' }); + expect(res).toHaveProperty('verses'); + expect(res).toHaveProperty('meta'); + }); + + it("Should fetch glyph codes of ayah v2", async () => { + const res: any = await quran.getGlyphCodesOfAyahV1({ page_number: '1' }); + expect(res).toHaveProperty('verses'); + expect(res).toHaveProperty('meta'); + }); + +}); \ No newline at end of file diff --git a/src/apis/quran.ts b/src/apis/quran.ts index a69b951..1d2e981 100644 --- a/src/apis/quran.ts +++ b/src/apis/quran.ts @@ -64,7 +64,7 @@ const quran: QuranApi = { }); }, getSingleTafsir(tafsir_id: string, query?: TranslationQuery): Promise { - const uri = query ? `/quran/tafsirs/${tafsir_id}/info?${new URLSearchParams(query as URLSearchParams)}` : `/quran/tafsirs/${tafsir_id}/info`; + const uri = query ? `/quran/tafsirs/${tafsir_id}?${new URLSearchParams(query as URLSearchParams)}` : `/quran/tafsirs/${tafsir_id}`; return new Promise((resolve, reject) => { api.get(uri) .then(handleResponse(resolve)) @@ -87,4 +87,6 @@ const quran: QuranApi = { .catch(handleError(reject)); }); }, -}; \ No newline at end of file +}; + +export default quran; \ No newline at end of file