mirror of
https://github.com/openclaw/clawhub.git
synced 2026-08-14 08:52:21 +00:00
- Enhanced AGENTS.md with clearer project structure and development commands. - Updated CHANGELOG.md to reflect recent fixes and additions. - Improved formatting in CONTRIBUTING.md for better readability. - Adjusted package.json and configuration files for consistent command structure. - Refined README.md and VISION.md for clarity and organization. - Standardized code formatting in various TypeScript files for consistency. These changes aim to enhance documentation clarity and maintainability across the repository.
36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
parseBooleanQueryParam,
|
|
parseBooleanQueryParamOptional,
|
|
resolveBooleanQueryParam,
|
|
} from "./httpUtils";
|
|
|
|
describe("parseBooleanQueryParam", () => {
|
|
it("returns true for true-like values", () => {
|
|
expect(parseBooleanQueryParam("true")).toBe(true);
|
|
expect(parseBooleanQueryParam("1")).toBe(true);
|
|
expect(parseBooleanQueryParam(" TRUE ")).toBe(true);
|
|
});
|
|
|
|
it("returns false for missing and false-like values", () => {
|
|
expect(parseBooleanQueryParam(null)).toBe(false);
|
|
expect(parseBooleanQueryParam("")).toBe(false);
|
|
expect(parseBooleanQueryParam("false")).toBe(false);
|
|
expect(parseBooleanQueryParam("0")).toBe(false);
|
|
expect(parseBooleanQueryParam("yes")).toBe(false);
|
|
});
|
|
|
|
it("supports optional parsing for precedence-sensitive callers", () => {
|
|
expect(parseBooleanQueryParamOptional(null)).toBeUndefined();
|
|
expect(parseBooleanQueryParamOptional("false")).toBe(false);
|
|
expect(parseBooleanQueryParamOptional("1")).toBe(true);
|
|
});
|
|
|
|
it("prefers the primary param over the legacy alias when both are present", () => {
|
|
expect(resolveBooleanQueryParam("false", "1")).toBe(false);
|
|
expect(resolveBooleanQueryParam("true", "0")).toBe(true);
|
|
expect(resolveBooleanQueryParam(null, "1")).toBe(true);
|
|
expect(resolveBooleanQueryParam(null, null)).toBeUndefined();
|
|
});
|
|
});
|