test: tighten shared message and ipv4 coverage

This commit is contained in:
Peter Steinberger 2026-03-13 21:37:48 +00:00
parent 80569babd3
commit 4fd8b98b10
2 changed files with 14 additions and 0 deletions

View File

@ -10,10 +10,19 @@ describe("shared/chat-message-content", () => {
).toBe("hello"); ).toBe("hello");
}); });
it("preserves empty-string text in the first block", () => {
expect(
extractFirstTextBlock({
content: [{ text: "" }, { text: "later" }],
}),
).toBe("");
});
it("returns undefined for missing, empty, or non-text content", () => { it("returns undefined for missing, empty, or non-text content", () => {
expect(extractFirstTextBlock(null)).toBeUndefined(); expect(extractFirstTextBlock(null)).toBeUndefined();
expect(extractFirstTextBlock({ content: [] })).toBeUndefined(); expect(extractFirstTextBlock({ content: [] })).toBeUndefined();
expect(extractFirstTextBlock({ content: [{ type: "image" }] })).toBeUndefined(); expect(extractFirstTextBlock({ content: [{ type: "image" }] })).toBeUndefined();
expect(extractFirstTextBlock({ content: ["hello"] })).toBeUndefined(); expect(extractFirstTextBlock({ content: ["hello"] })).toBeUndefined();
expect(extractFirstTextBlock({ content: [{ text: 1 }, { text: "later" }] })).toBeUndefined();
}); });
}); });

View File

@ -7,13 +7,18 @@ describe("shared/net/ipv4", () => {
"IP address is required for custom bind mode", "IP address is required for custom bind mode",
); );
expect(validateDottedDecimalIPv4Input("")).toBe("IP address is required for custom bind mode"); expect(validateDottedDecimalIPv4Input("")).toBe("IP address is required for custom bind mode");
expect(validateDottedDecimalIPv4Input(" ")).toBe(
"Invalid IPv4 address (e.g., 192.168.1.100)",
);
}); });
it("accepts canonical dotted-decimal ipv4 only", () => { it("accepts canonical dotted-decimal ipv4 only", () => {
expect(validateDottedDecimalIPv4Input("192.168.1.100")).toBeUndefined(); expect(validateDottedDecimalIPv4Input("192.168.1.100")).toBeUndefined();
expect(validateDottedDecimalIPv4Input(" 192.168.1.100 ")).toBeUndefined();
expect(validateDottedDecimalIPv4Input("0177.0.0.1")).toBe( expect(validateDottedDecimalIPv4Input("0177.0.0.1")).toBe(
"Invalid IPv4 address (e.g., 192.168.1.100)", "Invalid IPv4 address (e.g., 192.168.1.100)",
); );
expect(validateDottedDecimalIPv4Input("[192.168.1.100]")).toBeUndefined();
expect(validateDottedDecimalIPv4Input("example.com")).toBe( expect(validateDottedDecimalIPv4Input("example.com")).toBe(
"Invalid IPv4 address (e.g., 192.168.1.100)", "Invalid IPv4 address (e.g., 192.168.1.100)",
); );