// The per-platform seek rule (lane clip-kit): one table, two writers with their own policies, neither changed. import { test } from "node:test"; import assert from "node:assert/strict"; import { PLATFORM_SEEK, VOD_RETENTION_DAYS, seekPlatformOfUrl, seekRuleOf, seekValue } from "./platformSeek.mjs"; import { platformMomentUrl } from "./momentUrl"; import { watchUrlAt } from "./clips/assist.mjs"; import { VOD_RETENTION_DAYS as EXPIRY_DAYS } from "./vodExpiry"; test("the table: each platform's parameter and form; Kick and Rumble not verified", () => { assert.equal(seekValue(PLATFORM_SEEK.youtube, 3725.9), "3725s"); assert.equal(seekValue(PLATFORM_SEEK.twitch, 3725), "1h2m5s"); assert.equal(seekValue(PLATFORM_SEEK.kick, 10643.4), "10643"); assert.deepEqual(Object.entries(PLATFORM_SEEK).filter(([, r]) => !r.verified).map(([p]) => p), ["rumble", "kick"]); assert.equal(seekPlatformOfUrl("https://www.kick.com/x/videos/u"), "kick"); assert.equal(seekPlatformOfUrl("https://youtu.be/abc"), "youtube"); assert.equal(seekPlatformOfUrl("https://example.org/v"), null); assert.equal(seekRuleOf(null).key, "t"); assert.deepEqual(EXPIRY_DAYS, { ...VOD_RETENTION_DAYS }, "vodExpiry.ts reads the same numbers"); }); test("watchUrlAt writes every platform's parameter, as it always did", () => { assert.equal(watchUrlAt("https://www.youtube.com/watch?v=abc&t=5s", 61), "https://www.youtube.com/watch?v=abc&t=61s"); assert.equal(watchUrlAt("https://www.twitch.tv/videos/1", 3725), "https://www.twitch.tv/videos/1?t=1h2m5s"); assert.equal(watchUrlAt("https://rumble.com/v2abc-title.html", 61), "https://rumble.com/v2abc-title.html?start=61"); assert.equal(watchUrlAt("https://kick.com/somechan/videos/u-u-i-d?t=1", 10643.7), "https://kick.com/somechan/videos/u-u-i-d?t=10643"); assert.equal(watchUrlAt("https://example.org/v#frag", 7), "https://example.org/v?t=7#frag"); assert.equal(watchUrlAt("not a url", 7), null); }); test("platformMomentUrl writes only a verified parameter, as it always did", () => { assert.equal(platformMomentUrl("https://www.youtube.com/watch?v=abc", "youtube", 61), "https://www.youtube.com/watch?v=abc&t=61s"); assert.equal(platformMomentUrl("https://www.twitch.tv/videos/1", "twitch", 3725), "https://www.twitch.tv/videos/1?t=1h2m5s"); assert.equal(platformMomentUrl("https://odysee.com/@c/v", "odysee", 9), "https://odysee.com/@c/v?t=9"); assert.equal(platformMomentUrl("https://rumble.com/v2abc.html", "rumble", 61), "https://rumble.com/v2abc.html"); assert.equal(platformMomentUrl("https://kick.com/somechan/videos/u", "kick", 61), "https://kick.com/somechan/videos/u"); assert.equal(platformMomentUrl("https://kick.com/somechan/videos/u", "kick", 0), "https://kick.com/somechan/videos/u"); });