Add market watch and match hub workflows

这个提交包含在:
cryptocommuniums-afk
2026-04-07 11:00:03 +08:00
父节点 495da60212
当前提交 32ffad1545
修改 39 个文件,包含 6974 行新增330 行删除

29
server/_core/fetch.test.ts 普通文件
查看文件

@@ -0,0 +1,29 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { fetchWithTimeout } from "./fetch";
describe("fetchWithTimeout", () => {
afterEach(() => {
vi.restoreAllMocks();
vi.unstubAllGlobals();
});
it("retries timeout-like errors for allowed methods", async () => {
const fetchMock = vi.fn()
.mockRejectedValueOnce(new Error("Request timed out after 100ms"))
.mockResolvedValueOnce(new Response("ok", { status: 200 }));
vi.stubGlobal("fetch", fetchMock);
const response = await fetchWithTimeout("https://example.com", {
method: "POST",
}, {
timeoutMs: 100,
retries: 1,
retryMethods: ["POST"],
baseDelayMs: 1,
});
expect(response.ok).toBe(true);
expect(fetchMock).toHaveBeenCalledTimes(2);
});
});