fix(chapters): sort chapter list entries, localize strings, fix tick keys

This commit is contained in:
Uruk
2026-05-22 12:06:53 +02:00
parent e649414e3f
commit 87b181b66f
5 changed files with 50 additions and 9 deletions

View File

@@ -3,6 +3,7 @@ import {
chapterMarkers,
currentChapterIndex,
formatChapterTime,
sortedChapters,
} from "./chapters";
// Helper: a ChapterInfo with a start in milliseconds.
@@ -48,6 +49,23 @@ describe("currentChapterIndex", () => {
});
});
describe("sortedChapters", () => {
test("pairs each chapter with its ms start, sorted ascending", () => {
const a = ch(60_000, "C");
const b = ch(0, "A");
const c = ch(30_000, "B");
expect(sortedChapters([a, b, c])).toEqual([
{ chapter: b, positionMs: 0 },
{ chapter: c, positionMs: 30_000 },
{ chapter: a, positionMs: 60_000 },
]);
});
test("returns [] for null/undefined", () => {
expect(sortedChapters(null)).toEqual([]);
expect(sortedChapters(undefined)).toEqual([]);
});
});
describe("formatChapterTime", () => {
test("formats m:ss and h:mm:ss", () => {
expect(formatChapterTime(65_000)).toBe("1:05");