Skip to content

Commit f378710

Browse files
test(text): pin helper boundary semantics
1 parent 6c5f868 commit f378710

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎test/clawsweeper-text.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test("trimMiddle handles a maxLength below the head/tail overhead without garbag
88
// Regression: maxLength < 120 made `edge` negative — the slices read the wrong ends
99
// (slice(-0) returns the whole string) and the "truncated N" count exceeded text.length.
1010
const out = trimMiddle(text, 20);
11+
assert.equal(out, `${"x".repeat(20)}\n\n[truncated 5 chars]`);
1112
const m = out.match(/truncated (-?\d+) chars/);
1213
if (m) {
1314
const removed = Number(m[1]);
@@ -17,6 +18,9 @@ test("trimMiddle handles a maxLength below the head/tail overhead without garbag
1718
);
1819
}
1920
assert.ok(!out.includes(text), "must not echo the whole input via slice(-0)");
21+
22+
// At exactly 120 the computed edge is zero, so this boundary must use the same fallback.
23+
assert.equal(trimMiddle("x".repeat(125), 120), `${"x".repeat(120)}\n\n[truncated 5 chars]`);
2024
});
2125

2226
test("trimMiddle still middle-truncates for a normal large cap", () => {

‎test/repair/comment-router-utils.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,10 @@ test("normalizeGitHubActor is idempotent for repeated [bot] suffixes", () => {
14491449
assert.equal(normalizeGitHubActor(once), once);
14501450
// Unregressed: a single real bot suffix still strips exactly once.
14511451
assert.equal(normalizeGitHubActor("foo[bot]"), "foo");
1452+
assert.equal(normalizeGitHubActor(" Foo[bot] "), "foo");
1453+
assert.equal(normalizeGitHubActor("x[bot][bot]tail"), "x[bot][bot]tail");
1454+
assert.equal(normalizeGitHubActor(null), "");
1455+
assert.equal(normalizeGitHubActor(123), "123");
14521456
});
14531457

14541458
test("mutation actor guard recognizes GitHub App integration auth shape", () => {

‎test/repair/text-utils.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ test("compactText never exceeds maxLength, even for tiny caps", () => {
1212
}
1313
// Regression: maxLength 2 used to return the bare "..." (length 3).
1414
assert.equal(compactText("hello world", 2), "he");
15+
assert.equal(compactText("abcdefghijklmnopqrstuvwxyz", 3), "...");
16+
assert.equal(compactText("abcdefghijklmnopqrstuvwxyz", 4), "a...");
17+
assert.equal(compactText("abcdefghijklmnopqrstuvwxyz", 16), "abcdefghijklm...");
18+
assert.equal(compactText("abcdefghijklmnopqrstuvwxyz", 17), "abcdef ... uvwxyz");
1519
});
1620

1721
test("slug is idempotent (a trailing dash is not re-introduced by the length slice)", () => {
@@ -34,4 +38,5 @@ test("slug is idempotent (a trailing dash is not re-introduced by the length sli
3438
}
3539
// Unregressed: normal slugs are unchanged.
3640
assert.equal(slug("my-repo-name"), "my-repo-name");
41+
assert.equal(slug("a---b", "x", 3), "a");
3742
});

0 commit comments

Comments
 (0)