aboutsummaryrefslogtreecommitdiff
path: root/src/lib/List/Anime/rendering.test.ts
blob: 038e3729b238c35960e43d6e54d03846669abe24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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);
	});
});