mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: guard signal helper assertions
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,/,
|
||||
|
||||
Reference in New Issue
Block a user