diff --git a/README.md b/README.md
index cf05147..4717b43 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,10 @@
# Interpol.ts
-
-
-
+
+
+
+
+
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.
diff --git a/biome.json b/biome.json
index 004b882..1026ecb 100644
--- a/biome.json
+++ b/biome.json
@@ -9,7 +9,7 @@
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
- "rules": { "recommended": false },
+ "rules": { "recommended": true },
"ignore": ["dist", "./src/openapi.json"]
},
"overrides": [
diff --git a/src/services/InterpolService.test.ts b/src/services/InterpolService.test.ts
index 1f2440e..4577d1f 100644
--- a/src/services/InterpolService.test.ts
+++ b/src/services/InterpolService.test.ts
@@ -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();
+ });
});
});