diff --git a/api/src/db/schema/utils.ts b/api/src/db/schema/utils.ts index de882ff1..02f6e8af 100644 --- a/api/src/db/schema/utils.ts +++ b/api/src/db/schema/utils.ts @@ -20,4 +20,3 @@ export const externalid = () => >() .notNull() .default({}); - diff --git a/api/src/models/utils/external-id.ts b/api/src/models/utils/external-id.ts index dab28ea3..806c790d 100644 --- a/api/src/models/utils/external-id.ts +++ b/api/src/models/utils/external-id.ts @@ -1,13 +1,14 @@ import { t } from "elysia"; import { comment } from "../../utils"; -export const ExternalId = () => t.Record( - t.String(), - t.Object({ - dataId: t.String(), - link: t.Nullable(t.String({ format: "uri" })), - }), -); +export const ExternalId = () => + t.Record( + t.String(), + t.Object({ + dataId: t.String(), + link: t.Nullable(t.String({ format: "uri" })), + }), + ); export const EpisodeId = t.Record( t.String(), diff --git a/api/tests/helpers/movies-helper.ts b/api/tests/helpers/movies-helper.ts index f2317ea6..8ba77603 100644 --- a/api/tests/helpers/movies-helper.ts +++ b/api/tests/helpers/movies-helper.ts @@ -4,7 +4,10 @@ import type { SeedMovie } from "~/models/movie"; export const getMovie = async ( id: string, - { langs, ...query }: { langs?: string; preferOriginal?: boolean }, + { + langs, + ...query + }: { langs?: string; preferOriginal?: boolean; with?: string[] }, ) => { const resp = await app.handle( new Request(buildUrl(`movies/${id}`, query), { diff --git a/api/tests/helpers/series-helper.ts b/api/tests/helpers/series-helper.ts index 5997aeea..5c4dac8f 100644 --- a/api/tests/helpers/series-helper.ts +++ b/api/tests/helpers/series-helper.ts @@ -16,6 +16,27 @@ export const createSerie = async (serie: SeedSerie) => { return [resp, body] as const; }; +export const getSerie = async ( + id: string, + { + langs, + ...query + }: { langs?: string; preferOriginal?: boolean; with?: string[] }, +) => { + const resp = await app.handle( + new Request(buildUrl(`series/${id}`, query), { + method: "GET", + headers: langs + ? { + "Accept-Language": langs, + } + : {}, + }), + ); + const body = await resp.json(); + return [resp, body] as const; +}; + export const getSeasons = async ( serie: string, { diff --git a/api/tests/series/studios.test.ts b/api/tests/series/studios.test.ts index 6bbf5d8e..a23f9494 100644 --- a/api/tests/series/studios.test.ts +++ b/api/tests/series/studios.test.ts @@ -1,5 +1,5 @@ import { beforeAll, describe, expect, it } from "bun:test"; -import { getShowsByStudio, getStudio } from "tests/helpers"; +import { getSerie, getShowsByStudio, getStudio } from "tests/helpers"; import { expectStatus } from "tests/utils"; import { seedSerie } from "~/controllers/seed/series"; import { madeInAbyss } from "~/models/examples"; @@ -46,4 +46,19 @@ describe("Get a studio", () => { expectStatus(resp, body).toBe(200); expect(body.slug).toBe(slug); }); + it("Get using /shows?with=", async () => { + const [resp, body] = await getSerie(madeInAbyss.slug, { + langs: "en", + with: ["studios"], + }); + + expectStatus(resp, body).toBe(200); + expect(body.slug).toBe(madeInAbyss.slug); + expect(body.studios).toBeArrayOfSize(1); + const studio = madeInAbyss.studios[0]; + expect(body.studios[0]).toMatchObject({ + slug: studio.slug, + name: studio.translations.en.name, + }); + }); });