mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-04 00:16:50 +02:00
Merged via squash.
Prepared head SHA: d9a2869ad6
Co-authored-by: maweibin <18023423+maweibin@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
27 lines
939 B
TypeScript
27 lines
939 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { concatOptionalTextSegments, joinPresentTextSegments } from "./join-segments.js";
|
|
|
|
describe("concatOptionalTextSegments", () => {
|
|
it("concatenates left and right with default separator", () => {
|
|
expect(concatOptionalTextSegments({ left: "A", right: "B" })).toBe("A\n\nB");
|
|
});
|
|
|
|
it("keeps explicit empty-string right value", () => {
|
|
expect(concatOptionalTextSegments({ left: "A", right: "" })).toBe("");
|
|
});
|
|
});
|
|
|
|
describe("joinPresentTextSegments", () => {
|
|
it("joins non-empty segments", () => {
|
|
expect(joinPresentTextSegments(["A", undefined, "B"])).toBe("A\n\nB");
|
|
});
|
|
|
|
it("returns undefined when all segments are empty", () => {
|
|
expect(joinPresentTextSegments(["", undefined, null])).toBeUndefined();
|
|
});
|
|
|
|
it("trims segments when requested", () => {
|
|
expect(joinPresentTextSegments([" A ", " B "], { trim: true })).toBe("A\n\nB");
|
|
});
|
|
});
|