Fix video deduper timestamp comparison

This commit is contained in:
thePR0M3TH3AN committed 2025-10-27 09:57:12 -04:00
1 parent 46691b1578
commit d235839e22
2 files changed
+32 -1

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
import test from "node:test";
import assert from "node:assert/strict";
import { dedupeToNewestByRoot } from "../../js/utils/videoDeduper.js";
test("dedupeToNewestByRoot replaces entries with missing timestamps", () => {
const original = { id: "abc", created_at: undefined };
const newer = { id: "abc", created_at: 123 };
const [result] = dedupeToNewestByRoot([original, newer]);
assert.equal(result, newer);
});
test("dedupeToNewestByRoot replaces entries with non-numeric timestamps", () => {
const rootId = "root-1";
const invalid = { id: "old", videoRootId: rootId, created_at: "not-a-number" };
const newer = { id: "new", videoRootId: rootId, created_at: "456" };
const [result] = dedupeToNewestByRoot([invalid, newer]);
assert.equal(result, newer);
});