Add comprehensive test coverage for services and utilities

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 08:08:22 +01:00
co-authored by Claude Haiku 4.5
parent e3797f32ca
commit 57f8a54dac
23 changed files with 3519 additions and 20 deletions
+11 -9
View File
@@ -11,16 +11,17 @@ describe("formatDuration", () => {
it("should format duration from Jellyfin ticks (mm:ss format)", () => {
// 1 second = 10,000,000 ticks
expect(formatDuration(10000000)).toBe("0:01");
expect(formatDuration(60000000)).toBe("1:00");
expect(formatDuration(600000000)).toBe("10:00");
expect(formatDuration(3661000000)).toBe("61:01");
expect(formatDuration(60000000)).toBe("0:06");
expect(formatDuration(600000000)).toBe("1:00");
expect(formatDuration(6000000000)).toBe("10:00");
expect(formatDuration(36610000000)).toBe("61:01");
});
it("should format duration with hh:mm:ss format", () => {
// 1 hour = 3600 seconds
// 1 hour = 3600 seconds = 36,000,000,000 ticks
expect(formatDuration(36000000000, "hh:mm:ss")).toBe("1:00:00");
expect(formatDuration(36600000000, "hh:mm:ss")).toBe("1:01:40");
expect(formatDuration(3661000000, "hh:mm:ss")).toBe("0:01:01");
expect(formatDuration(36100000000, "hh:mm:ss")).toBe("1:00:10");
expect(formatDuration(36610000000, "hh:mm:ss")).toBe("1:01:01");
});
it("should return empty string for undefined or 0 ticks", () => {
@@ -29,12 +30,13 @@ describe("formatDuration", () => {
});
it("should pad seconds with leading zero", () => {
expect(formatDuration(5000000)).toBe("0:05");
expect(formatDuration(15000000)).toBe("0:15");
expect(formatDuration(5000000)).toBe("0:00");
expect(formatDuration(50000000)).toBe("0:05");
expect(formatDuration(150000000)).toBe("0:15");
});
it("should handle large durations", () => {
// 2 hours 30 minutes 45 seconds
// 2 hours 30 minutes 45 seconds = 9045 seconds * 10,000,000 ticks/second
expect(formatDuration(90450000000, "hh:mm:ss")).toBe("2:30:45");
});
});