Files
openclaw/src/shared/human-list.test.ts
dwc1997 f936c6b495 test(shared): add unit tests for human-readable list formatting
Squashed from PR #98605 after updating branch with current main and passing CI.
2026-07-01 06:42:54 -07:00

26 lines
802 B
TypeScript

// Tests for human-readable list formatting.
import { describe, expect, it } from "vitest";
import { formatHumanList } from "./human-list.js";
describe("formatHumanList", () => {
it("returns empty string for empty array", () => {
expect(formatHumanList([])).toBe("");
});
it("returns the value for single element", () => {
expect(formatHumanList(["apple"])).toBe("apple");
});
it("joins two elements with or", () => {
expect(formatHumanList(["apple", "banana"])).toBe("apple or banana");
});
it("joins three elements with comma and or", () => {
expect(formatHumanList(["apple", "banana", "cherry"])).toBe("apple, banana, or cherry");
});
it("joins four or more elements", () => {
expect(formatHumanList(["a", "b", "c", "d"])).toBe("a, b, c, or d");
});
});