import { test, expect } from "bun:test"; import { buildCommitMessage, noreplyEmail } from "./a31_commit_meta.ts"; test("buildCommitMessage emits the expected subject + trailer", () => { const msg = buildCommitMessage({ title: "S — Sorted", author: "syntaxai", filePath: "content/sama/sorted.md", }); const lines = msg.split("\n"); expect(lines[0]).toBe("edit content/sama/sorted.md via web"); expect(msg).toContain("Submitted by syntaxai via the tdd.md self-hosted editor."); }); test("buildCommitMessage filePath is the only thing on the subject line", () => { // Important: keeps `git log --oneline` readable. No author / no SHA // hint in the subject — that's all in the body / trailers / metadata. const msg = buildCommitMessage({ title: "ignored title", author: "syntaxai", filePath: "content/blog/some-post.md", }); const subject = msg.split("\n")[0]; expect(subject).toBe("edit content/blog/some-post.md via web"); expect(subject).not.toContain("syntaxai"); expect(subject).not.toContain("ignored title"); }); test("noreplyEmail prefers the github-id form when available", () => { expect(noreplyEmail("syntaxai", 12766340)).toBe( "12766340+syntaxai@users.noreply.github.com", ); }); test("noreplyEmail falls back to login-only when id is unknown", () => { expect(noreplyEmail("syntaxai")).toBe("syntaxai@users.noreply.github.com"); });