feat(casting): extract reusable next-episode helpers

This commit is contained in:
Uruk
2026-05-23 23:18:55 +02:00
parent 0ba3d19550
commit 57cfa5ce78
3 changed files with 73 additions and 21 deletions

View File

@@ -0,0 +1,19 @@
import { describe, expect, test } from "bun:test";
import { findNextEpisode } from "./episodes";
const ep = (id: string) => ({ Id: id });
describe("findNextEpisode", () => {
test("returns the episode after the current one", () => {
expect(findNextEpisode([ep("a"), ep("b"), ep("c")], "b")).toEqual(ep("c"));
});
test("returns null on the last episode", () => {
expect(findNextEpisode([ep("a"), ep("b")], "b")).toBeNull();
});
test("returns null when the current id is not found", () => {
expect(findNextEpisode([ep("a"), ep("b")], "x")).toBeNull();
});
test("returns null for an empty list", () => {
expect(findNextEpisode([], "a")).toBeNull();
});
});