mirror of
http://192.168.0.88:13333/lywsvip/openclaw-zero-token.git
synced 2026-05-08 16:17:54 +08:00
Major upgrade from e26988a38 to upstream v2026.3.28 (f9b107928).
Key changes:
- Upstream src/, ui/, extensions/ (89 bundled extensions)
- Zero-token web providers preserved in src/zero-token/
- AskOnce plugin restored and registered as CLI command
- Added missing packages: @anthropic-ai/vertex-sdk, @modelcontextprotocol/sdk
- Fixed tsconfig rootDir, skipLibCheck for plugin-sdk DTS build
- Added askonce to bundled plugin metadata and package.json exports
- Fixed AskOnce CLI command registration (missing commands metadata)
- Restored AskOnce adapter imports (correct 5-level relative paths)
- Removed stale migration artifacts from root directory
44 lines
1.6 KiB
TypeScript
44 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { parseTimeoutMs, parseTimeoutMsWithFallback } from "./parse-timeout.js";
|
|
|
|
describe("parseTimeoutMs", () => {
|
|
it("parses positive string values", () => {
|
|
expect(parseTimeoutMs("1500")).toBe(1500);
|
|
});
|
|
|
|
it("returns undefined for empty or invalid values", () => {
|
|
expect(parseTimeoutMs(undefined)).toBeUndefined();
|
|
expect(parseTimeoutMs("")).toBeUndefined();
|
|
expect(parseTimeoutMs("nope")).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe("parseTimeoutMsWithFallback", () => {
|
|
it("returns the fallback for missing or empty values", () => {
|
|
expect(parseTimeoutMsWithFallback(undefined, 3000)).toBe(3000);
|
|
expect(parseTimeoutMsWithFallback(null, 3000)).toBe(3000);
|
|
expect(parseTimeoutMsWithFallback(" ", 3000)).toBe(3000);
|
|
});
|
|
|
|
it("parses positive numbers and strings", () => {
|
|
expect(parseTimeoutMsWithFallback(2500, 3000)).toBe(2500);
|
|
expect(parseTimeoutMsWithFallback(2500n, 3000)).toBe(2500);
|
|
expect(parseTimeoutMsWithFallback("2500", 3000)).toBe(2500);
|
|
});
|
|
|
|
it("falls back on unsupported types by default", () => {
|
|
expect(parseTimeoutMsWithFallback({}, 3000)).toBe(3000);
|
|
});
|
|
|
|
it("throws on unsupported types when requested", () => {
|
|
expect(() => parseTimeoutMsWithFallback({}, 3000, { invalidType: "error" })).toThrow(
|
|
"invalid --timeout",
|
|
);
|
|
});
|
|
|
|
it("throws on non-positive parsed values", () => {
|
|
expect(() => parseTimeoutMsWithFallback("0", 3000)).toThrow("invalid --timeout: 0");
|
|
expect(() => parseTimeoutMsWithFallback("-1", 3000)).toThrow("invalid --timeout: -1");
|
|
});
|
|
});
|