From 873e26adbbca1686d3a3e6e59ea92e4f0165810c Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 8 May 2026 19:10:29 +0100 Subject: [PATCH] test: tighten synology chat tls assertions --- extensions/synology-chat/src/client.test.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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 }); }); });