mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-02 20:18:29 +01:00
feat(casting): extract reusable next-episode helpers
This commit is contained in:
19
utils/casting/episodes.test.ts
Normal file
19
utils/casting/episodes.test.ts
Normal 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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user