22 lines
1.3 KiB
TypeScript
22 lines
1.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { postAuthorLabel } from "../lib/display";
|
|
import { memoUrl } from "../lib/memos";
|
|
|
|
test("formats Memos authors as remote user at source hostname", () => {
|
|
assert.equal(postAuthorLabel({ origin: "memos", username: "hub-user", name: "唐宋打油", remote_user: "users/tangsong", remote_display_name: "唐宋打油", source_base_url: "https://memos.fishking.studio/path" }), "@tangsong@memos.fishking.studio");
|
|
});
|
|
|
|
test("formats Hub posts linked to Memos with the same source identity", () => {
|
|
assert.equal(postAuthorLabel({ origin: "hub", username: "codex", name: "唐宋打油", remote_user: "users/tangsong", remote_display_name: "唐宋打油", source_base_url: "https://memos.fishking.studio" }), "@tangsong@memos.fishking.studio");
|
|
});
|
|
|
|
test("keeps the existing label for non-Memos posts", () => {
|
|
assert.equal(postAuthorLabel({ origin: "hub", username: "codex", name: "Hub", source_base_url: null }), "@codex");
|
|
});
|
|
|
|
test("uses current Memos UID links while preserving legacy numeric links", () => {
|
|
assert.equal(memoUrl("https://memos.example.com/", "memos/VA54SvJG7yBparf3SiH3Ey"), "https://memos.example.com/memos/VA54SvJG7yBparf3SiH3Ey");
|
|
assert.equal(memoUrl("https://memos.example.com", "memos/15"), "https://memos.example.com/m/15");
|
|
});
|