aboutsummaryrefslogtreecommitdiff
path: root/src/lib/List/Anime/rendering.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/List/Anime/rendering.test.ts')
-rw-r--r--src/lib/List/Anime/rendering.test.ts96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/lib/List/Anime/rendering.test.ts b/src/lib/List/Anime/rendering.test.ts
new file mode 100644
index 00000000..038e3729
--- /dev/null
+++ b/src/lib/List/Anime/rendering.test.ts
@@ -0,0 +1,96 @@
+import { describe, expect, it } from "vitest";
+import type { Media } from "$lib/Data/AniList/media";
+import { shouldRenderAnimeCover } from "$lib/List/Anime/rendering";
+
+const baseMedia = (id: number): Media =>
+ ({
+ id,
+ idMal: id,
+ status: "RELEASING",
+ type: "ANIME",
+ episodes: 12,
+ chapters: 0,
+ volumes: 0,
+ duration: 24,
+ format: "TV",
+ title: {
+ romaji: `Fixture Show ${id}`,
+ english: `Fixture Show ${id}`,
+ native: `Fixture Show ${id}`,
+ },
+ nextAiringEpisode: {
+ episode: 9,
+ nativeEpisode: 10,
+ airingAt: Math.floor(Date.now() / 1000) + 24 * 60 * 60,
+ nativeAiringAt: Math.floor(Date.now() / 1000) + 36 * 60 * 60,
+ },
+ synonyms: [],
+ mediaListEntry: {
+ progress: 8,
+ progressVolumes: 0,
+ status: "CURRENT",
+ score: 0,
+ repeat: 0,
+ startedAt: {
+ year: 2026,
+ month: 1,
+ day: 1,
+ },
+ completedAt: {
+ year: 0,
+ month: 0,
+ day: 0,
+ },
+ createdAt: 0,
+ updatedAt: 0,
+ customLists: {},
+ },
+ startDate: {
+ year: 2026,
+ month: 1,
+ },
+ endDate: {
+ year: 2026,
+ month: 12,
+ },
+ coverImage: {
+ extraLarge: "https://example.com/cover-xl.jpg",
+ medium: "https://example.com/cover-md.jpg",
+ },
+ tags: [],
+ genres: [],
+ season: "WINTER",
+ isAdult: false,
+ relations: {
+ edges: [],
+ },
+ }) as Media;
+
+describe("anime cover rendering", () => {
+ it("renders due media when nativeEpisode indicates user is behind", () => {
+ const media = baseMedia(194028);
+
+ expect(
+ shouldRenderAnimeCover(media, {
+ upcoming: false,
+ notYetReleased: false,
+ }),
+ ).toBe(true);
+ });
+
+ it("hides caught-up releasing media outside upcoming lists", () => {
+ const media = baseMedia(194028);
+
+ media.mediaListEntry = {
+ ...(media.mediaListEntry as NonNullable<typeof media.mediaListEntry>),
+ progress: 9,
+ };
+
+ expect(
+ shouldRenderAnimeCover(media, {
+ upcoming: false,
+ notYetReleased: false,
+ }),
+ ).toBe(false);
+ });
+});