Files
tsumugu/frontend/src/list-meta.test.mjs
T
LarsandCursor e4380261fc
Deploy Development / deploy (push) Successful in 29s
Test Suite / pytest-backend (push) Successful in 1m24s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 9s
Verkuerze die Inhaltsliste und fuehre Unterkapitel ein, damit Richtung, Bezuge und Struktur ohne Zusatzzeilen bedienbar bleiben.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-17 21:13:21 +02:00

39 lines
1.6 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { bezugCount, counterpartLabel, directionSymbol, partyLabel } from "./list-meta.mjs";
test("party names stay short and ignore address chains", () => {
assert.equal(partyLabel("Karin Vogel <karin.vogel@example.org>"), "Karin Vogel");
assert.equal(partyLabel('"Kanzlei Beispiel" <kanzlei@example.org>, Ablage <ablage@example.org>'), "Kanzlei Beispiel");
assert.equal(partyLabel("ablage@example.org"), "ablage");
});
test("incoming mail shows the sender and outgoing mail the recipient", () => {
const element = {
external: {
source: "imap",
detail: {
message_from: "Karin Vogel <karin.vogel@example.org>",
message_to: "Kanzlei Beispiel <kanzlei@example.org>",
},
},
};
assert.equal(counterpartLabel(element, "in"), "Karin Vogel");
assert.equal(counterpartLabel(element, "out"), "Kanzlei Beispiel");
assert.equal(counterpartLabel({ kind: "note" }, "local"), "");
});
test("direction symbols distinguish local, unspecified and the triangles", () => {
assert.equal(directionSymbol("in"), "communication-in");
assert.equal(directionSymbol("out"), "communication-out");
assert.equal(directionSymbol("local"), "communication-local");
assert.equal(directionSymbol(""), "communication-unspecified");
assert.equal(directionSymbol(null), "communication-unspecified");
});
test("bezug counts only readable disclosed counterparts", () => {
assert.equal(bezugCount({ refers_to: [{ id: "a" }], referred_by: [{ id: "b" }, { id: "c" }] }), 3);
assert.equal(bezugCount({}), 0);
assert.equal(bezugCount(null), 0);
});