test: guard signal helper assertions

This commit is contained in:
Peter Steinberger
2026-05-11 19:47:29 +01:00
parent f2bb32f09f
commit 199838616c
2 changed files with 12 additions and 4 deletions

View File

@@ -95,12 +95,16 @@ function expectRpcCall(params: {
if (params.rpcParams) {
expectFields(requireRecord(rpcParams, "rpc params"), params.rpcParams);
} else {
expect(rpcParams).toBeDefined();
if (rpcParams === undefined) {
throw new Error("expected rpc params argument");
}
}
if (params.options) {
expectFields(requireRecord(options, "rpc options"), params.options);
} else {
expect(options).toBeDefined();
if (options === undefined) {
throw new Error("expected rpc options argument");
}
}
}

View File

@@ -288,7 +288,9 @@ describe("containerRestRequest", () => {
// The timeout is enforced via AbortController, so we verify the call was made with a signal
expect(mockFetch).toHaveBeenCalled();
expect(requireFetchCall()[1].signal).toBeDefined();
if (requireFetchCall()[1].signal === undefined) {
throw new Error("expected fetch call to include an abort signal");
}
});
});
@@ -428,7 +430,9 @@ describe("containerSendMessage", () => {
const callArgs = mockFetch.mock.calls[0];
const body = JSON.parse(callArgs[1].body);
expect(body.attachments).toBeUndefined();
expect(body.base64_attachments).toBeDefined();
if (!Array.isArray(body.base64_attachments)) {
throw new Error("expected base64 attachments array");
}
expect(body.base64_attachments).toHaveLength(1);
expect(body.base64_attachments[0]).toMatch(
/^data:image\/jpeg;filename=test-image\.jpg;base64,/,