-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcommitmsg.test.ts
More file actions
39 lines (33 loc) · 1.37 KB
/
Copy pathcommitmsg.test.ts
File metadata and controls
39 lines (33 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
import { assertEquals } from "@std/assert";
import { extractCommitLine } from "./commitmsg.ts";
Deno.test("extractCommitLine returns a clean single conventional line as-is", () => {
assertEquals(
extractCommitLine("feat(mux): add terminal multiplexer"),
"feat(mux): add terminal multiplexer",
);
});
Deno.test("extractCommitLine pulls the last conforming line out of chatty agent output", () => {
const chatty =
"conventional commit message: feat(mux): add frontend-neutral multiplexer\n\n" +
"That's 71 chars. Let me verify the scope.\n\n" +
"feat(mux): add terminal multiplexer and agent adapters with native PTY\n\n" +
"Output only the line.";
assertEquals(
extractCommitLine(chatty),
"feat(mux): add terminal multiplexer and agent adapters with native PTY",
);
});
Deno.test("extractCommitLine supports scopes, !, and all conventional types", () => {
assertEquals(extractCommitLine("fix: handle null"), "fix: handle null");
assertEquals(
extractCommitLine("refactor(api)!: drop v1"),
"refactor(api)!: drop v1",
);
});
Deno.test("extractCommitLine falls back to the first non-empty line when nothing matches", () => {
assertEquals(
extractCommitLine("\n updated the readme \nsecond line"),
"updated the readme",
);
});