Download src/utils/utils-misc.test.ts from shimen/shinclaw: direct link, hf CLI and curl.
- Browser
- Download file 3.41 kB
-
https://huggingface.co/spaces/shimen/shinclaw/resolve/main/src/utils/utils-misc.test.ts
- Command line
-
hf download hf://spaces/shimen/shinclaw/src/utils/utils-misc.test.ts
-
curl -L -o utils-misc.test.ts https://huggingface.co/spaces/shimen/shinclaw/resolve/main/src/utils/utils-misc.test.ts
3.41 kB
| import { describe, expect, it } from "vitest"; | |
| import { parseBooleanValue } from "./boolean.js"; | |
| import { isReasoningTagProvider } from "./provider-utils.js"; | |
| import { splitShellArgs } from "./shell-argv.js"; | |
| describe("parseBooleanValue", () => { | |
| it("handles boolean inputs", () => { | |
| expect(parseBooleanValue(true)).toBe(true); | |
| expect(parseBooleanValue(false)).toBe(false); | |
| }); | |
| it("parses default truthy/falsy strings", () => { | |
| expect(parseBooleanValue("true")).toBe(true); | |
| expect(parseBooleanValue("1")).toBe(true); | |
| expect(parseBooleanValue("yes")).toBe(true); | |
| expect(parseBooleanValue("on")).toBe(true); | |
| expect(parseBooleanValue("false")).toBe(false); | |
| expect(parseBooleanValue("0")).toBe(false); | |
| expect(parseBooleanValue("no")).toBe(false); | |
| expect(parseBooleanValue("off")).toBe(false); | |
| }); | |
| it("respects custom truthy/falsy lists", () => { | |
| expect( | |
| parseBooleanValue("on", { | |
| truthy: ["true"], | |
| falsy: ["false"], | |
| }), | |
| ).toBeUndefined(); | |
| expect( | |
| parseBooleanValue("yes", { | |
| truthy: ["yes"], | |
| falsy: ["no"], | |
| }), | |
| ).toBe(true); | |
| }); | |
| it("returns undefined for unsupported values", () => { | |
| expect(parseBooleanValue("")).toBeUndefined(); | |
| expect(parseBooleanValue("maybe")).toBeUndefined(); | |
| expect(parseBooleanValue(1)).toBeUndefined(); | |
| }); | |
| }); | |
| describe("isReasoningTagProvider", () => { | |
| it("returns false for ollama - native reasoning field, no tags needed (#2279)", () => { | |
| expect(isReasoningTagProvider("ollama")).toBe(false); | |
| expect(isReasoningTagProvider("Ollama")).toBe(false); | |
| }); | |
| it("returns true for google-gemini-cli", () => { | |
| expect(isReasoningTagProvider("google-gemini-cli")).toBe(true); | |
| }); | |
| it("returns true for google-generative-ai", () => { | |
| expect(isReasoningTagProvider("google-generative-ai")).toBe(true); | |
| }); | |
| it("returns true for google-antigravity", () => { | |
| expect(isReasoningTagProvider("google-antigravity")).toBe(true); | |
| expect(isReasoningTagProvider("google-antigravity/gemini-3")).toBe(true); | |
| }); | |
| it("returns true for minimax", () => { | |
| expect(isReasoningTagProvider("minimax")).toBe(true); | |
| expect(isReasoningTagProvider("minimax-cn")).toBe(true); | |
| }); | |
| it("returns false for null/undefined/empty", () => { | |
| expect(isReasoningTagProvider(null)).toBe(false); | |
| expect(isReasoningTagProvider(undefined)).toBe(false); | |
| expect(isReasoningTagProvider("")).toBe(false); | |
| }); | |
| it("returns false for standard providers", () => { | |
| expect(isReasoningTagProvider("anthropic")).toBe(false); | |
| expect(isReasoningTagProvider("openai")).toBe(false); | |
| expect(isReasoningTagProvider("openrouter")).toBe(false); | |
| }); | |
| }); | |
| describe("splitShellArgs", () => { | |
| it("splits whitespace and respects quotes", () => { | |
| expect(splitShellArgs(`qmd --foo "bar baz"`)).toEqual(["qmd", "--foo", "bar baz"]); | |
| expect(splitShellArgs(`qmd --foo 'bar baz'`)).toEqual(["qmd", "--foo", "bar baz"]); | |
| }); | |
| it("supports backslash escapes inside double quotes", () => { | |
| expect(splitShellArgs(String.raw`echo "a\"b"`)).toEqual(["echo", `a"b`]); | |
| expect(splitShellArgs(String.raw`echo "\$HOME"`)).toEqual(["echo", "$HOME"]); | |
| }); | |
| it("returns null for unterminated quotes", () => { | |
| expect(splitShellArgs(`echo "oops`)).toBeNull(); | |
| expect(splitShellArgs(`echo 'oops`)).toBeNull(); | |
| }); | |
| }); | |