mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Test ?with=
This commit is contained in:
parent
750434465d
commit
cdf4ab4941
@ -20,4 +20,3 @@ export const externalid = () =>
|
||||
>()
|
||||
.notNull()
|
||||
.default({});
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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), {
|
||||
|
@ -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,
|
||||
{
|
||||
|
@ -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,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user