Kyoo/api/tests/series/get-entries.test.ts
2025-03-01 23:48:21 +01:00

49 lines
1.3 KiB
TypeScript

import { beforeAll, describe, expect, it } from "bun:test";
import { getEntries, getExtras } from "tests/helpers";
import { expectStatus } from "tests/utils";
import { seedSerie } from "~/controllers/seed/series";
import { madeInAbyss } from "~/models/examples";
let miaId = "";
beforeAll(async () => {
const ret = await seedSerie(madeInAbyss);
if (!("status" in ret)) miaId = ret.id;
});
describe("Get entries", () => {
it("Invalid slug", async () => {
const [resp, body] = await getEntries("sotneuhn", { langs: "en" });
expectStatus(resp, body).toBe(404);
expect(body).toMatchObject({
status: 404,
message: expect.any(String),
});
});
it("Default sort order", async () => {
const [resp, body] = await getEntries(madeInAbyss.slug, { langs: "en" });
expectStatus(resp, body).toBe(200);
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);
});
});