Files
openclaw/test/scripts/real-behavior-proof-check.test.ts
2026-05-27 15:12:53 +02:00

43 lines
1.3 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { fetchProofComments } from "../../scripts/github/real-behavior-proof-check.mjs";
describe("real-behavior-proof-check GitHub lookups", () => {
it("aborts stalled proof comment fetches", async () => {
const fetch = vi.fn((_url: URL, init: RequestInit) => {
return new Promise((_resolve, reject) => {
init.signal?.addEventListener("abort", () => reject(init.signal?.reason));
});
});
await expect(
fetchProofComments({
fetchImpl: fetch as typeof globalThis.fetch,
issueNumber: 123,
owner: "openclaw",
repo: "openclaw",
timeoutMs: 5,
tokens: ["tok"],
}),
).rejects.toThrow(/proof comment lookup page 1 timed out after 5ms/);
});
it("times out stalled proof comment response bodies", async () => {
const fetch = vi.fn().mockResolvedValue({
ok: true,
status: 200,
json: () => new Promise(() => {}),
});
await expect(
fetchProofComments({
fetchImpl: fetch as typeof globalThis.fetch,
issueNumber: 123,
owner: "openclaw",
repo: "openclaw",
timeoutMs: 5,
tokens: ["tok"],
}),
).rejects.toThrow(/proof comment response page 1 timed out after 5ms/);
});
});