test: tighten synology chat tls assertions

This commit is contained in:
Shakker
2026-05-08 19:10:29 +01:00
parent 25cac63563
commit 873e26adbb

View File

@@ -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 });
});
});