From b332b7dff72905cb0cdb779d8475b6ce8341dea6 Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 8 May 2026 19:13:38 +0100 Subject: [PATCH] test: tighten zalo api request assertions --- extensions/zalo/src/api.test.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/extensions/zalo/src/api.test.ts b/extensions/zalo/src/api.test.ts index cdcef5a2dfb..919d6f0b4b7 100644 --- a/extensions/zalo/src/api.test.ts +++ b/extensions/zalo/src/api.test.ts @@ -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(); }