Files
buzz/desktop/src/shared/api/tauriFeed.test.mjs
Tyler da2e2592a3 fix(desktop): stop DMs from firing duplicate desktop notifications (#2105)
Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
2026-07-18 23:16:00 -04:00

36 lines
1.0 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { fromRawFeedItem } from "./tauri.ts";
const rawFeedItem = (overrides = {}) => ({
id: "event-id",
kind: 9,
pubkey: "author",
content: "hello",
created_at: 1,
channel_id: "channel-id",
channel_name: "",
channel_type: null,
tags: [["h", "channel-id"]],
category: "mention",
...overrides,
});
test("canonicalizes the native null channel_type to undefined", () => {
// Native get_feed serializes FeedItemInfo.channel_type (Option<String>)
// as `null`, never omitting the key. FeedItem declares channelType as
// optional, and the DM notification filter distinguishes "unresolved"
// via `=== undefined` — so null must not survive the boundary.
const item = fromRawFeedItem(rawFeedItem());
assert.equal(item.channelType, undefined);
assert.ok("channelType" in item);
});
test("passes a present channel_type through unchanged", () => {
const item = fromRawFeedItem(rawFeedItem({ channel_type: "dm" }));
assert.equal(item.channelType, "dm");
});