mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Test get seasons
This commit is contained in:
parent
6a30173628
commit
b5460682c9
@ -16,6 +16,35 @@ export const createSerie = async (serie: SeedSerie) => {
|
||||
return [resp, body] as const;
|
||||
};
|
||||
|
||||
export const getSeasons = async (
|
||||
serie: string,
|
||||
{
|
||||
langs,
|
||||
...opts
|
||||
}: {
|
||||
filter?: string;
|
||||
limit?: number;
|
||||
after?: string;
|
||||
sort?: string | string[];
|
||||
query?: string;
|
||||
langs?: string;
|
||||
preferOriginal?: boolean;
|
||||
},
|
||||
) => {
|
||||
const resp = await app.handle(
|
||||
new Request(buildUrl(`series/${serie}/seasons`, opts), {
|
||||
method: "GET",
|
||||
headers: langs
|
||||
? {
|
||||
"Accept-Language": langs,
|
||||
}
|
||||
: {},
|
||||
}),
|
||||
);
|
||||
const body = await resp.json();
|
||||
return [resp, body] as const;
|
||||
};
|
||||
|
||||
export const getEntries = async (
|
||||
serie: string,
|
||||
{
|
||||
|
30
api/tests/series/get-seasons.test.ts
Normal file
30
api/tests/series/get-seasons.test.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { beforeAll, describe, expect, it } from "bun:test";
|
||||
import { getSeasons } 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 seasons", () => {
|
||||
it("Invalid slug", async () => {
|
||||
const [resp, body] = await getSeasons("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 getSeasons(madeInAbyss.slug, { langs: "en" });
|
||||
|
||||
expectStatus(resp, body).toBe(200);
|
||||
expect(body.items).toBeArrayOfSize(madeInAbyss.seasons.length);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user