Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+33
@@ -0,0 +1,33 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { fetchProvider, readProviderJson } from "./provider-http.js";
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
describe("provider HTTP boundary", () => {
|
||||
it("disables redirects and supplies an abort signal", async () => {
|
||||
const fetchMock = vi.fn<typeof fetch>(async () => new Response("{}"));
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
await fetchProvider("https://provider.example.test/api", { headers: { authorization: "Bearer secret" } });
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(
|
||||
"https://provider.example.test/api",
|
||||
expect.objectContaining({ redirect: "error", signal: expect.any(AbortSignal) })
|
||||
);
|
||||
});
|
||||
|
||||
it("rejects oversized JSON from both content-length and streamed bytes", async () => {
|
||||
const declared = new Response("{}", { headers: { "content-length": "99" } });
|
||||
await expect(readProviderJson(declared, 8)).rejects.toThrow("size limit");
|
||||
|
||||
const streamed = new Response('{"large":true}');
|
||||
await expect(readProviderJson(streamed, 8)).rejects.toThrow("size limit");
|
||||
});
|
||||
|
||||
it("parses a bounded JSON response", async () => {
|
||||
await expect(readProviderJson<{ ok: boolean }>(new Response('{"ok":true}'))).resolves.toEqual({ ok: true });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user