39 lines
1.6 KiB
JavaScript
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);
|
|
});
|