import { describe, expect, it } from "vitest"; import { normalizeMessageId, parseReferencesHeader, resolveThreadMeta, } from "@/services/parse/thread"; describe("thread split", () => { it("normalizes message id", () => { expect(normalizeMessageId("")).toBe("a@b.com"); expect(normalizeMessageId(" a@b.com ")).toBe("a@b.com"); }); it("root message is thread root", () => { const t = resolveThreadMeta({ messageId: "", 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: "", inReplyTo: "", references: " ", }); 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: "", inReplyTo: "", references: "", }); expect(current.threadId).toBe("new@x"); expect(current.isThreadRoot).toBe(false); // 类型由 classify(当前 subject) 决定,不由 thread 继承 }); it("parseReferencesHeader", () => { expect(parseReferencesHeader(" ")).toEqual(["a@x", "b@x"]); }); });