Skip to content

Commit

Permalink
feat: quran api tested
Browse files Browse the repository at this point in the history
  • Loading branch information
PrantaDas committed Aug 7, 2024
1 parent 6d94c15 commit 04069dc
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
62 changes: 62 additions & 0 deletions src/apis/quran.test.ts
Original file line number Diff line number Diff line change
@@ -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');
});

});
6 changes: 4 additions & 2 deletions src/apis/quran.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const quran: QuranApi = {
});
},
getSingleTafsir(tafsir_id: string, query?: TranslationQuery): Promise<SingleTafsirResponse | AxiosError | Error> {
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))
Expand All @@ -87,4 +87,6 @@ const quran: QuranApi = {
.catch(handleError(reject));
});
},
};
};

export default quran;

0 comments on commit 04069dc

Please sign in to comment.