diff --git a/extensions/synology-chat/src/client.test.ts b/extensions/synology-chat/src/client.test.ts index d5c55db21bb..37bf9cd26a4 100644 --- a/extensions/synology-chat/src/client.test.ts +++ b/extensions/synology-chat/src/client.test.ts @@ -121,7 +121,12 @@ describe("Synology Chat TLS verification defaults", () => { mockSuccessResponse(); await settleTimers(invoke()); const httpsRequest = vi.mocked(https.request); - expect(httpsRequest.mock.calls[0]?.[1]).toMatchObject({ rejectUnauthorized: true }); + const firstCall = httpsRequest.mock.calls[0]; + expect(firstCall).toBeDefined(); + if (!firstCall) { + throw new Error("expected Synology Chat HTTPS request"); + } + expect(firstCall[1]).toMatchObject({ rejectUnauthorized: true }); }); }); @@ -153,7 +158,12 @@ describe("sendMessage", () => { mockSuccessResponse(); await settleTimers(sendMessage("https://nas.example.com/incoming", "Hello", undefined, true)); const httpsRequest = vi.mocked(https.request); - expect(httpsRequest.mock.calls[0]?.[1]).toMatchObject({ rejectUnauthorized: false }); + const firstCall = httpsRequest.mock.calls[0]; + expect(firstCall).toBeDefined(); + if (!firstCall) { + throw new Error("expected Synology Chat HTTPS request"); + } + expect(firstCall[1]).toMatchObject({ rejectUnauthorized: false }); }); }); @@ -376,6 +386,11 @@ describe("fetchChatUsers", () => { await fetchChatUsers(freshUrl); const httpsGet = vi.mocked(https.get); - expect(httpsGet.mock.calls[0]?.[1]).toMatchObject({ rejectUnauthorized: true }); + const firstCall = httpsGet.mock.calls[0]; + expect(firstCall).toBeDefined(); + if (!firstCall) { + throw new Error("expected Synology Chat HTTPS get"); + } + expect(firstCall[1]).toMatchObject({ rejectUnauthorized: true }); }); });