add vitest for fetchUrlContent

This commit is contained in:
Patrick Erichsen 2025-10-17 10:00:17 -07:00
parent 96c1573474
commit 48cef4256d

View file

@ -89,3 +89,13 @@ test("fetchUrlContent should add truncation warning with multiple truncated item
expect(result[1].content.length).toBe(DEFAULT_FETCH_URL_CHAR_LIMIT);
expect(result[2].name).toBe("Truncation warning");
});
test("fetchUrlContent should propagate errors when URL fetch fails", async () => {
const errorMessage = "HTTP 404 Not Found";
(getUrlContextItems as any).mockRejectedValue(new Error(errorMessage));
await expect(
fetchUrlContentImpl({ url: "https://example.com/404" }, mockExtras)
).rejects.toThrow(errorMessage);
});