Files
tech-log-frontend/tests/unit/read-bounded-boot-json.test.ts

32 lines
837 B
TypeScript

import { describe, expect, it } from "vitest";
import {
BOOT_JSON_POLICIES,
readBoundedBootJson,
} from "../../src/bootstrap/read-bounded-boot-json.ts";
describe("bounded boot JSON admission", () => {
it("does not call fetch when the caller signal is already aborted", async () => {
const caller = new AbortController();
caller.abort();
let fetchCalls = 0;
const outcome = await readBoundedBootJson(
"/config.json",
BOOT_JSON_POLICIES.RUNTIME_CONFIG,
{
signal: caller.signal,
fetcher: async () => {
fetchCalls += 1;
return new Response("{}", {
headers: { "content-type": "application/json" },
});
},
},
);
expect(fetchCalls).toBe(0);
expect(outcome).toEqual({ ok: false, failure: "FETCH_FAILED" });
});
});