You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
import { describe, expect, it } from "vitest";
|
|
import {
|
|
normalizeMessageId,
|
|
parseReferencesHeader,
|
|
resolveThreadMeta,
|
|
} from "@/services/parse/thread";
|
|
|
|
describe("thread split", () => {
|
|
it("normalizes message id", () => {
|
|
expect(normalizeMessageId("<a@b.com>")).toBe("a@b.com");
|
|
expect(normalizeMessageId(" a@b.com ")).toBe("a@b.com");
|
|
});
|
|
|
|
it("root message is thread root", () => {
|
|
const t = resolveThreadMeta({
|
|
messageId: "<root@x>",
|
|
inReplyTo: null,
|
|
references: null,
|
|
});
|
|
expect(t.isThreadRoot).toBe(true);
|
|
expect(t.threadId).toBe("root@x");
|
|
});
|
|
|
|
it("reply uses References leftmost as threadId", () => {
|
|
const t = resolveThreadMeta({
|
|
messageId: "<reply2@x>",
|
|
inReplyTo: "<reply1@x>",
|
|
references: "<root@x> <reply1@x>",
|
|
});
|
|
expect(t.isThreadRoot).toBe(false);
|
|
expect(t.threadId).toBe("root@x");
|
|
expect(t.inReplyTo).toBe("reply1@x");
|
|
});
|
|
|
|
it("M4-like: current label does not inherit root NEW by thread alone", () => {
|
|
const current = resolveThreadMeta({
|
|
messageId: "<label@x>",
|
|
inReplyTo: "<new@x>",
|
|
references: "<new@x>",
|
|
});
|
|
expect(current.threadId).toBe("new@x");
|
|
expect(current.isThreadRoot).toBe(false);
|
|
// 类型由 classify(当前 subject) 决定,不由 thread 继承
|
|
});
|
|
|
|
it("parseReferencesHeader", () => {
|
|
expect(parseReferencesHeader("<a@x> <b@x>")).toEqual(["a@x", "b@x"]);
|
|
});
|
|
});
|