fix(playlists): "+N without length" counts every video the sum left out
The label said "without length" but the count held only live videos, so a video not fetched yet, or gone before it was, was left out of the sum and named nowhere. The server's `Video.without_length` and the client's `isWithoutLength` are now one rule (no length, whatever the live status), and the field, the key and the helpers are named for what they count. The comments that still quoted "+N live" say the current copy.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { TFunction } from "i18next";
|
||||
import { isWithoutLength, withLeftOutCount } from "./withoutLength";
|
||||
|
||||
const t = ((key: string, o: { count: number }) => `${key}:${o.count}`) as unknown as TFunction;
|
||||
|
||||
describe("a total and the videos it cannot hold", () => {
|
||||
it("counts every video the server sent no length for", () => {
|
||||
expect(isWithoutLength({ duration_seconds: null })).toBe(true);
|
||||
expect(isWithoutLength({ duration_seconds: 5400 })).toBe(false);
|
||||
expect(isWithoutLength({ duration_seconds: 0 })).toBe(false);
|
||||
});
|
||||
|
||||
it("names them beside the sum, or alone when nothing summed", () => {
|
||||
expect(withLeftOutCount("12 hr 5 min", 2, t)).toBe("12 hr 5 min card.withoutLength:2");
|
||||
expect(withLeftOutCount("", 1, t)).toBe("card.withoutLength:1");
|
||||
expect(withLeftOutCount("12 hr 5 min", 0, t)).toBe("12 hr 5 min");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user