mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Add tests for preferOriginal in /movies
This commit is contained in:
parent
a558f47558
commit
a734a40668
@ -199,4 +199,82 @@ describe("Get all movies", () => {
|
||||
expect(isUuid(id)).toBe(true);
|
||||
});
|
||||
});
|
||||
it("Limit 2, fallback lang, prefer original", async () => {
|
||||
const [resp, body] = await getMovies({
|
||||
limit: 2,
|
||||
langs: "en-au",
|
||||
preferOriginal: true,
|
||||
});
|
||||
|
||||
expectStatus(resp, body).toBe(200);
|
||||
expect(body.items[0]).toMatchObject({
|
||||
slug: bubble.slug,
|
||||
name: bubble.translations.en.name,
|
||||
poster: {
|
||||
source: bubble.translations.ja.poster,
|
||||
},
|
||||
thumbnail: {
|
||||
source: bubble.translations.ja.thumbnail,
|
||||
},
|
||||
banner: null,
|
||||
// we fallback to the translated value when the original is null.
|
||||
logo: { source: bubble.translations.en.logo },
|
||||
});
|
||||
expect(body.items[1]).toMatchObject({
|
||||
slug: dune.slug,
|
||||
name: dune.translations.en.name,
|
||||
});
|
||||
});
|
||||
it("Limit 2, * lang, prefer original", async () => {
|
||||
const [resp, body] = await getMovies({
|
||||
limit: 2,
|
||||
langs: "*",
|
||||
preferOriginal: true,
|
||||
});
|
||||
|
||||
expectStatus(resp, body).toBe(200);
|
||||
expect(body.items[0]).toMatchObject({
|
||||
slug: bubble.slug,
|
||||
name: bubble.translations.en.name,
|
||||
poster: {
|
||||
source: bubble.translations.ja.poster,
|
||||
},
|
||||
thumbnail: {
|
||||
source: bubble.translations.ja.thumbnail,
|
||||
},
|
||||
banner: null,
|
||||
// we fallback to the translated value when the original is null.
|
||||
logo: { source: bubble.translations.en.logo },
|
||||
});
|
||||
expect(body.items[1]).toMatchObject({
|
||||
slug: dune.slug,
|
||||
name: dune.translations.en.name,
|
||||
});
|
||||
});
|
||||
it("Limit 2, unknown lang, prefer original", async () => {
|
||||
const [resp, body] = await getMovies({
|
||||
limit: 2,
|
||||
langs: "toto",
|
||||
preferOriginal: true,
|
||||
});
|
||||
|
||||
expectStatus(resp, body).toBe(200);
|
||||
expect(body.items[0]).toMatchObject({
|
||||
slug: bubble.slug,
|
||||
name: bubble.translations.en.name,
|
||||
poster: {
|
||||
source: bubble.translations.ja.poster,
|
||||
},
|
||||
thumbnail: {
|
||||
source: bubble.translations.ja.thumbnail,
|
||||
},
|
||||
banner: null,
|
||||
// we fallback to the translated value when the original is null.
|
||||
logo: { source: bubble.translations.en.logo },
|
||||
});
|
||||
expect(body.items[1]).toMatchObject({
|
||||
slug: dune.slug,
|
||||
name: dune.translations.en.name,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -101,15 +101,15 @@ describe("Get movie", () => {
|
||||
expect(body).toMatchObject({
|
||||
slug: bubble.slug,
|
||||
name: bubble.translations.en.name,
|
||||
poster: ({
|
||||
poster: {
|
||||
source: bubble.translations.ja.poster,
|
||||
}),
|
||||
thumbnail: ({
|
||||
},
|
||||
thumbnail: {
|
||||
source: bubble.translations.ja.thumbnail,
|
||||
}),
|
||||
},
|
||||
banner: null,
|
||||
// we fallback to the translated value when the original is null.
|
||||
logo: ({ source: bubble.translations.en.logo }),
|
||||
logo: { source: bubble.translations.en.logo },
|
||||
});
|
||||
expect(resp.headers.get("Content-Language")).toBe("en");
|
||||
});
|
||||
|
@ -34,6 +34,7 @@ export const getMovies = async ({
|
||||
after?: string;
|
||||
sort?: string | string[];
|
||||
langs?: string;
|
||||
preferOriginal?: boolean;
|
||||
}) => {
|
||||
const resp = await movieApp.handle(
|
||||
new Request(buildUrl("movies", query), {
|
||||
|
Loading…
x
Reference in New Issue
Block a user