diff --git a/api/tests/helpers/series-helper.ts b/api/tests/helpers/series-helper.ts index 8ff3580d..bbdd6171 100644 --- a/api/tests/helpers/series-helper.ts +++ b/api/tests/helpers/series-helper.ts @@ -73,3 +73,38 @@ export const getEntries = async ( const body = await resp.json(); return [resp, body] as const; }; + +export const getExtras = async ( + serie: string, + opts: { + filter?: string; + limit?: number; + after?: string; + sort?: string | string[]; + query?: string; + }, +) => { + const resp = await app.handle( + new Request(buildUrl(`series/${serie}/extras`, opts), { + method: "GET", + }), + ); + const body = await resp.json(); + return [resp, body] as const; +}; + +export const getUnknowns = async (opts: { + filter?: string; + limit?: number; + after?: string; + sort?: string | string[]; + query?: string; +}) => { + const resp = await app.handle( + new Request(buildUrl(`unknowns`, opts), { + method: "GET", + }), + ); + const body = await resp.json(); + return [resp, body] as const; +}; diff --git a/api/tests/series/get-entries.test.ts b/api/tests/series/get-entries.test.ts index ae70e1f8..5384cde4 100644 --- a/api/tests/series/get-entries.test.ts +++ b/api/tests/series/get-entries.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from "bun:test"; -import { getEntries } from "tests/helpers"; +import { getEntries, getExtras } from "tests/helpers"; import { expectStatus } from "tests/utils"; import { seedSerie } from "~/controllers/seed/series"; import { madeInAbyss } from "~/models/examples"; @@ -28,3 +28,21 @@ describe("Get entries", () => { expect(body.items).toBeArrayOfSize(madeInAbyss.entries.length); }); }); + +describe("Get extra", () => { + it("Invalid slug", async () => { + const [resp, body] = await getExtras("sotneuhn", {}); + + expectStatus(resp, body).toBe(404); + expect(body).toMatchObject({ + status: 404, + message: expect.any(String), + }); + }); + it("Default sort order", async () => { + const [resp, body] = await getExtras(madeInAbyss.slug, {}); + + expectStatus(resp, body).toBe(200); + expect(body.items).toBeArrayOfSize(madeInAbyss.extras.length); + }); +});