mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
24 lines
783 B
JavaScript
24 lines
783 B
JavaScript
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);
|
|
});
|