mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 14:50:44 +00:00
test: tighten zalo api request assertions
This commit is contained in:
@@ -18,8 +18,12 @@ async function expectPostJsonRequest(run: (token: string, fetcher: ZaloFetch) =>
|
||||
await run("test-token", fetcher);
|
||||
expect(fetcher).toHaveBeenCalledTimes(1);
|
||||
const [, init] = fetcher.mock.calls[0] ?? [];
|
||||
expect(init?.method).toBe("POST");
|
||||
expect(init?.headers).toEqual({ "Content-Type": "application/json" });
|
||||
expect(init).toBeDefined();
|
||||
if (!init) {
|
||||
throw new Error("expected Zalo request init");
|
||||
}
|
||||
expect(init.method).toBe("POST");
|
||||
expect(init.headers).toEqual({ "Content-Type": "application/json" });
|
||||
}
|
||||
|
||||
describe("Zalo API request methods", () => {
|
||||
@@ -67,7 +71,15 @@ describe("Zalo API request methods", () => {
|
||||
|
||||
await rejected;
|
||||
const [, init] = fetcher.mock.calls[0] ?? [];
|
||||
expect(init?.signal?.aborted).toBe(true);
|
||||
expect(init).toBeDefined();
|
||||
if (!init) {
|
||||
throw new Error("expected Zalo chat action request init");
|
||||
}
|
||||
expect(init.signal).toBeDefined();
|
||||
if (!init.signal) {
|
||||
throw new Error("expected Zalo chat action abort signal");
|
||||
}
|
||||
expect(init.signal.aborted).toBe(true);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user