Skip to content

Commit

Permalink
refactor: biome reconfig & test rearrangement
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakub Rekowski authored and Jakub Rekowski committed Oct 20, 2024
1 parent 44154bd commit 86d6bec
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 14 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Interpol.ts

<img src="./assets/red_notice.svg" height="150px" />
<img src="./assets/yellow_notice.svg" height="150px" />
<img src="./assets/un_notice.svg" height="150px" />
<a href="https://interpol.int/en/How-we-work/Notices" align="center">
<img src="./assets/red_notice.svg" height="150px" alt="Red Notice" />
<img src="./assets/yellow_notice.svg" height="150px" alt="Yellow Notice" />
<img src="./assets/un_notice.svg" height="150px" alt="UN Notice" />
</a>

A TypeScript library for easily interacting with the Interpol public Notices API. This library provides a convenient, type-safe way to access data on Red, Yellow, and possibly in the future, other Interpol notices.

Expand Down
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": { "recommended": false },
"rules": { "recommended": true },
"ignore": ["dist", "./src/openapi.json"]
},
"overrides": [
Expand Down
61 changes: 51 additions & 10 deletions src/services/InterpolService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,60 @@ import { InterpolService } from "./InterpolService";
describe("InterpolService", () => {
let noticeID: string;

it("should get red notices", async () => {
const result = await InterpolService.getRedNotices();
expect(result).toBeDefined();
noticeID = result._embedded.notices.pop().entity_id.replace("/", "-");
describe("getRedNotices", () => {
it("should return red notices when API call is successful", async () => {
const redNotices = await InterpolService.getRedNotices();
expect(redNotices).toBeDefined();
expect(Array.isArray(redNotices._embedded.notices)).toBe(true);
expect(redNotices._embedded.notices.length).toBeGreaterThan(0);

if (redNotices._embedded.notices.length > 0) {
noticeID = redNotices._embedded.notices[0].entity_id.replace("/", "-");
expect(noticeID).toBeTruthy();
} else {
console.warn("No red notices found. Subsequent tests may fail.");
}
});

it("should handle empty result", async () => {
const redNotices = await InterpolService.getRedNotices({
name: "imposibble-name",
});
expect(redNotices).toBeDefined();
expect(Array.isArray(redNotices._embedded.notices)).toBe(true);
expect(redNotices._embedded.notices.length).toBe(0);
});
});

it("should get red notice details", async () => {
const result = await InterpolService.getRedNoticeDetails(noticeID);
expect(result).toBeDefined();
describe("getRedNoticeDetails", () => {
it("should return red notice details when API call is successful", async () => {
expect(noticeID).toBeTruthy();

const noticeDetails = await InterpolService.getRedNoticeDetails(noticeID);
expect(noticeDetails).toBeDefined();
expect(noticeDetails.entity_id).toBe(noticeID.replace("-", "/"));
});

it("should throw an error when API call fails by providing an invalid notice ID", async () => {
await expect(
InterpolService.getRedNoticeDetails("invalid-notice-id")
).rejects.toThrow();
});
});

it("should get red notice detail images", async () => {
const result = await InterpolService.getRedNoticeDetailImages(noticeID);
expect(result).toBeDefined();
describe("getRedNoticeDetailImages", () => {
it("should return red notice detail images when API call is successful", async () => {
expect(noticeID).toBeTruthy();

const images = await InterpolService.getRedNoticeDetailImages(noticeID);
expect(images).toBeDefined();
expect(Array.isArray(images._embedded.images)).toBe(true);
});

it("should throw an error when API call fails by providing an invalid notice ID", async () => {
await expect(
InterpolService.getRedNoticeDetails("invalid-notice-id")
).rejects.toThrow();
});
});
});

0 comments on commit 86d6bec

Please sign in to comment.