diff --git a/src/shared/string-normalization.test.ts b/src/shared/string-normalization.test.ts index ca92a8ae89c..e0f8c8ae900 100644 --- a/src/shared/string-normalization.test.ts +++ b/src/shared/string-normalization.test.ts @@ -29,10 +29,20 @@ describe("shared/string-normalization", () => { expect(normalizeHyphenSlug(null)).toBe(""); }); + it("collapses repeated separators and trims leading/trailing punctuation", () => { + expect(normalizeHyphenSlug(" ...Hello / World--- ")).toBe("hello-world"); + expect(normalizeHyphenSlug(" ###Team@@@Room### ")).toBe("###team@@@room###"); + }); + it("normalizes @/# prefixed slugs used by channel allowlists", () => { expect(normalizeAtHashSlug(" #My_Channel + Alerts ")).toBe("my-channel-alerts"); expect(normalizeAtHashSlug("@@Room___Name")).toBe("room-name"); expect(normalizeAtHashSlug(undefined)).toBe(""); expect(normalizeAtHashSlug(null)).toBe(""); }); + + it("strips repeated prefixes and collapses separator-only results", () => { + expect(normalizeAtHashSlug("###__Room Name__")).toBe("room-name"); + expect(normalizeAtHashSlug("@@@___")).toBe(""); + }); }); diff --git a/src/shared/text/join-segments.test.ts b/src/shared/text/join-segments.test.ts index 279516e4269..8da5c4644a7 100644 --- a/src/shared/text/join-segments.test.ts +++ b/src/shared/text/join-segments.test.ts @@ -9,6 +9,12 @@ describe("concatOptionalTextSegments", () => { it("keeps explicit empty-string right value", () => { expect(concatOptionalTextSegments({ left: "A", right: "" })).toBe(""); }); + + it("falls back to whichever side is present and honors custom separators", () => { + expect(concatOptionalTextSegments({ left: "A" })).toBe("A"); + expect(concatOptionalTextSegments({ right: "B" })).toBe("B"); + expect(concatOptionalTextSegments({ left: "A", right: "B", separator: " | " })).toBe("A | B"); + }); }); describe("joinPresentTextSegments", () => { @@ -23,4 +29,11 @@ describe("joinPresentTextSegments", () => { it("trims segments when requested", () => { expect(joinPresentTextSegments([" A ", " B "], { trim: true })).toBe("A\n\nB"); }); + + it("keeps whitespace-only segments unless trim is enabled and supports custom separators", () => { + expect(joinPresentTextSegments(["A", " ", "B"], { separator: " | " })).toBe("A | | B"); + expect(joinPresentTextSegments(["A", " ", "B"], { trim: true, separator: " | " })).toBe( + "A | B", + ); + }); });