Files
buzz/desktop/src/features/messages/useThreadReplies.test.mjs
Tyler b0ad2b66dd Retain a stable message window in channel timelines (#1698)
Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
Signed-off-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
2026-07-12 21:41:38 -04:00

31 lines
766 B
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { collectThreadAuxMessageIds } from "./useThreadReplies.ts";
const ROOT_ID = "1".repeat(64);
const REPLY_ID = "2".repeat(64);
function reply(id = REPLY_ID) {
return {
id,
pubkey: "a".repeat(64),
kind: 9,
created_at: 1_700_000_000,
content: "reply",
tags: [["e", ROOT_ID]],
sig: "sig",
};
}
test("thread aux hydration includes the root when there are no replies", () => {
assert.deepEqual(collectThreadAuxMessageIds(ROOT_ID, []), [ROOT_ID]);
});
test("thread aux hydration includes and deduplicates root and reply ids", () => {
assert.deepEqual(
collectThreadAuxMessageIds(ROOT_ID, [reply(), reply(ROOT_ID)]),
[ROOT_ID, REPLY_ID],
);
});