Browse Source

fix: unit tests for routes with 0 matches

Sv443 4 months ago
parent
commit
cf55cd15d1
3 changed files with 13 additions and 13 deletions
  1. 4 4
      test/album.spec.ts
  2. 4 4
      test/search.spec.ts
  3. 5 5
      test/translations.spec.ts

+ 4 - 4
test/album.spec.ts

@@ -19,15 +19,15 @@ describe("Album routes", () => {
 
   //#region inv /album/:id
 
-  it("Invalid song ID yields error", async () => {
+  it("Invalid song ID yields no matches", async () => {
     const { res, status } = await sendReq("/album/0");
     const body = await res.json();
 
-    expect(status).toBe(400);
+    expect(status).toBe(200);
 
-    expect(body?.error).toEqual(true);
+    expect(body?.error).toEqual(false);
     expect(body?.matches).toEqual(0);
-    expect(body?.message).toBeDefined();
+    expect(body?.message).toBeUndefined();
   });
 
   //#region inv /album

+ 4 - 4
test/search.spec.ts

@@ -57,15 +57,15 @@ describe("Search routes", () => {
 
   //#region inv /search
 
-  it("Invalid search yields error", async () => {
+  it("Invalid search yields no matches", async () => {
     const randText = randomBytes(32).toString("hex");
     const { res, status } = await sendReq(`/search?q=${randText}`);
     const body = await res.json();
 
-    expect(status).toBe(400);
+    expect(status).toBe(200);
 
-    expect(body?.error).toEqual(true);
+    expect(body?.error).toEqual(false);
     expect(body?.matches).toEqual(0);
-    expect(body?.message).toBeDefined();
+    expect(body?.message).toBeUndefined();
   });
 });

+ 5 - 5
test/translations.spec.ts

@@ -19,15 +19,15 @@ describe("Translation routes", () => {
 
   //#region inv /translations/:id
 
-  it("Invalid song ID yields error", async () => {
+  it("Invalid song ID yields no matches", async () => {
     const { res, status } = await sendReq("/translations/0");
     const body = await res.json();
 
-    expect(status).toBe(400);
+    expect(status).toBe(200);
 
-    expect(body?.error).toEqual(true);
-    expect(body?.matches).toEqual(null);
-    expect(body?.message).toBeDefined();
+    expect(body?.error).toEqual(false);
+    expect(body?.matches).toEqual(0);
+    expect(body?.message).toBeUndefined();
   });
 
   //#region inv /translations