@agnishc/edb-herald 0.10.8 → 0.10.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.10.9] - 2026-05-18
4
+
3
5
  ## [0.10.8] - 2026-05-18
4
6
 
5
7
  ## [0.10.6] - 2026-05-15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agnishc/edb-herald",
3
- "version": "0.10.8",
3
+ "version": "0.10.9",
4
4
  "description": "Pi extension: git commit and PR agent with approval gates",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -0,0 +1,87 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { parseMode, truncate } from "./git.js";
3
+
4
+ describe("parseMode", () => {
5
+ it("returns 'commit' for exact 'commit'", () => {
6
+ expect(parseMode("commit")).toBe("commit");
7
+ });
8
+
9
+ it("is case-insensitive for 'commit'", () => {
10
+ expect(parseMode("COMMIT")).toBe("commit");
11
+ expect(parseMode("Commit")).toBe("commit");
12
+ });
13
+
14
+ it("returns 'pr' for exact 'pr'", () => {
15
+ expect(parseMode("pr")).toBe("pr");
16
+ });
17
+
18
+ it("is case-insensitive for 'pr'", () => {
19
+ expect(parseMode("PR")).toBe("pr");
20
+ expect(parseMode("Pr")).toBe("pr");
21
+ });
22
+
23
+ it("returns 'both' for exact 'both'", () => {
24
+ expect(parseMode("both")).toBe("both");
25
+ });
26
+
27
+ it("is case-insensitive for 'both'", () => {
28
+ expect(parseMode("BOTH")).toBe("both");
29
+ expect(parseMode("Both")).toBe("both");
30
+ });
31
+
32
+ it("trims whitespace from input", () => {
33
+ expect(parseMode(" commit ")).toBe("commit");
34
+ expect(parseMode(" pr ")).toBe("pr");
35
+ expect(parseMode(" both ")).toBe("both");
36
+ });
37
+
38
+ it("defaults to 'both' for unrecognized input", () => {
39
+ expect(parseMode("anything")).toBe("both");
40
+ expect(parseMode("random")).toBe("both");
41
+ });
42
+
43
+ it("returns 'both' for empty string", () => {
44
+ expect(parseMode("")).toBe("both");
45
+ });
46
+ });
47
+
48
+ describe("truncate", () => {
49
+ it("returns text unchanged when under maxLen", () => {
50
+ expect(truncate("hello", 10)).toBe("hello");
51
+ });
52
+
53
+ it("returns text unchanged when exactly maxLen", () => {
54
+ expect(truncate("hello", 5)).toBe("hello");
55
+ });
56
+
57
+ it("truncates text longer than maxLen", () => {
58
+ const result = truncate("hello world", 5);
59
+ expect(result).toContain("hello");
60
+ expect(result).toContain("...");
61
+ expect(result).toContain("truncated");
62
+ });
63
+
64
+ it("omits correct number of characters", () => {
65
+ const result = truncate("hello world", 5);
66
+ // "hello" is 5 chars, rest is " world" (6 chars)
67
+ expect(result).toContain("6 additional");
68
+ });
69
+
70
+ it("handles maxLen=0", () => {
71
+ const result = truncate("hello world", 0);
72
+ expect(result).toContain("...");
73
+ expect(result).toContain("truncated");
74
+ });
75
+
76
+ it("handles maxLen=1", () => {
77
+ const result = truncate("abc", 1);
78
+ expect(result).toContain("a");
79
+ expect(result).toContain("...");
80
+ expect(result).toContain("2 additional");
81
+ });
82
+
83
+ it("handles empty string", () => {
84
+ const result = truncate("", 10);
85
+ expect(result).toBe("");
86
+ });
87
+ });