mirror of https://github.com/openclaw/openclaw.git
test: tighten shared text normalization coverage
This commit is contained in:
parent
0c79c86b40
commit
090c0c4b5d
|
|
@ -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("");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue