From daca6c9df202b5b14d41992983ad31591759aafc Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 13 Mar 2026 21:48:40 +0000 Subject: [PATCH] test: tighten small shared helper coverage --- src/shared/assistant-identity-values.test.ts | 2 ++ src/shared/model-param-b.test.ts | 2 ++ src/shared/net/ipv4.test.ts | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/src/shared/assistant-identity-values.test.ts b/src/shared/assistant-identity-values.test.ts index f0e594cc7e7..ef3440ee2a0 100644 --- a/src/shared/assistant-identity-values.test.ts +++ b/src/shared/assistant-identity-values.test.ts @@ -10,6 +10,7 @@ describe("shared/assistant-identity-values", () => { it("trims values and preserves strings within the limit", () => { expect(coerceIdentityValue(" OpenClaw ", 20)).toBe("OpenClaw"); + expect(coerceIdentityValue(" OpenClaw ", 8)).toBe("OpenClaw"); }); it("truncates overlong trimmed values at the exact limit", () => { @@ -18,5 +19,6 @@ describe("shared/assistant-identity-values", () => { it("returns an empty string when truncating to a zero-length limit", () => { expect(coerceIdentityValue(" OpenClaw ", 0)).toBe(""); + expect(coerceIdentityValue(" OpenClaw ", -1)).toBe("OpenCla"); }); }); diff --git a/src/shared/model-param-b.test.ts b/src/shared/model-param-b.test.ts index 7fb9a7b82d4..8bbafe3f529 100644 --- a/src/shared/model-param-b.test.ts +++ b/src/shared/model-param-b.test.ts @@ -6,6 +6,7 @@ describe("shared/model-param-b", () => { expect(inferParamBFromIdOrName("llama-8b mixtral-22b")).toBe(22); expect(inferParamBFromIdOrName("Qwen 0.5B Instruct")).toBe(0.5); expect(inferParamBFromIdOrName("prefix M7B and q4_32b")).toBe(32); + expect(inferParamBFromIdOrName("(70b) + m1.5b + qwen-14b")).toBe(70); }); it("ignores malformed, zero, and non-delimited matches", () => { @@ -13,5 +14,6 @@ describe("shared/model-param-b", () => { expect(inferParamBFromIdOrName("model 0b")).toBeNull(); expect(inferParamBFromIdOrName("model b5")).toBeNull(); expect(inferParamBFromIdOrName("foo70bbar")).toBeNull(); + expect(inferParamBFromIdOrName("ab7b model")).toBeNull(); }); }); diff --git a/src/shared/net/ipv4.test.ts b/src/shared/net/ipv4.test.ts index 21ff99b982b..40dd024138f 100644 --- a/src/shared/net/ipv4.test.ts +++ b/src/shared/net/ipv4.test.ts @@ -13,12 +13,16 @@ describe("shared/net/ipv4", () => { }); it("accepts canonical dotted-decimal ipv4 only", () => { + expect(validateDottedDecimalIPv4Input("0.0.0.0")).toBeUndefined(); expect(validateDottedDecimalIPv4Input("192.168.1.100")).toBeUndefined(); expect(validateDottedDecimalIPv4Input(" 192.168.1.100 ")).toBeUndefined(); expect(validateDottedDecimalIPv4Input("0177.0.0.1")).toBe( "Invalid IPv4 address (e.g., 192.168.1.100)", ); expect(validateDottedDecimalIPv4Input("[192.168.1.100]")).toBeUndefined(); + expect(validateDottedDecimalIPv4Input("127.1")).toBe( + "Invalid IPv4 address (e.g., 192.168.1.100)", + ); expect(validateDottedDecimalIPv4Input("example.com")).toBe( "Invalid IPv4 address (e.g., 192.168.1.100)", );