pr_01m47d15m3e54sn21z27rpy5n9/apps/web/app/lib/commit-message.test.ts
| 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; |
| 3 | |
| 4 | import { parseCommitMessage } from "./commit-message.ts"; |
| 5 | |
| 6 | test("co-authors leave the body and keep only their names", () => { |
| 7 | const parsed = parseCommitMessage( |
| 8 | "Document every option\n\nAdds the missing rows.\n\nCo-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>", |
| 9 | ); |
| 10 | assert.equal(parsed.subject, "Document every option"); |
| 11 | assert.equal(parsed.body, "Adds the missing rows."); |
| 12 | assert.deepEqual(parsed.coAuthors, ["Claude Sonnet 5.5"]); |
| 13 | assert.deepEqual(parsed.trailers, []); |
| 14 | }); |
| 15 | |
| 16 | test("a message that is only trailers has no body", () => { |
| 17 | const parsed = parseCommitMessage("Fix it\n\nCo-Authored-By: Ada <ada@example.com>\nG1t-Pull: syntaqx/hello#72"); |
| 18 | assert.equal(parsed.body, ""); |
| 19 | assert.deepEqual(parsed.coAuthors, ["Ada"]); |
| 20 | assert.deepEqual(parsed.trailers, [{ key: "G1t-Pull", value: "syntaqx/hello#72" }]); |
| 21 | }); |
| 22 | |
| 23 | test("prose that happens to contain a colon stays prose", () => { |
| 24 | const parsed = parseCommitMessage("Fix it\n\nNote: this also renames a function.\nAnd tidies the tests."); |
| 25 | assert.equal(parsed.body, "Note: this also renames a function.\nAnd tidies the tests."); |
| 26 | assert.deepEqual(parsed.coAuthors, []); |
| 27 | }); |