mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-04 06:21:51 +00:00
* refactor(auto-reply): canonicalize inbound text once * chore(plugin-sdk): refresh API baseline * refactor(auto-reply): narrow finalized template context * test(auto-reply): keep runner fixtures structurally compatible * fix(auto-reply): guard optional post-command agent text * fix(auto-reply): finalize intercepted gateway context * fix(ci): register iOS release planner entries
29 lines
921 B
TypeScript
29 lines
921 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { isStringOption, readTrimmedStringAlias } from "./string-readers.js";
|
|
|
|
describe("string readers", () => {
|
|
it("checks caller-owned string options from arrays and sets", () => {
|
|
const modes = ["off", "auto"] as const;
|
|
const states = new Set(["ready", "done"] as const);
|
|
|
|
expect(isStringOption("auto", modes)).toBe(true);
|
|
expect(isStringOption(" AUTO ", modes)).toBe(false);
|
|
expect(isStringOption("done", states)).toBe(true);
|
|
expect(isStringOption(1, modes)).toBe(false);
|
|
});
|
|
|
|
it("reads trimmed aliases", () => {
|
|
const record = {
|
|
empty: "",
|
|
spaced: " value ",
|
|
fallback: "fallback",
|
|
invalid: 1,
|
|
};
|
|
|
|
expect(readTrimmedStringAlias(record, ["invalid", "empty", "spaced", "fallback"])).toBe(
|
|
"value",
|
|
);
|
|
expect(readTrimmedStringAlias(record, ["invalid", "empty"])).toBeUndefined();
|
|
});
|
|
});
|