mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-26 09:05:14 +00:00
test: tighten signal action assertions
This commit is contained in:
@@ -95,14 +95,21 @@ describe("signalRpcRequest", () => {
|
||||
res.end("not-json");
|
||||
});
|
||||
|
||||
await expect(
|
||||
signalRpcRequest("version", undefined, {
|
||||
let thrown: unknown;
|
||||
try {
|
||||
await signalRpcRequest("version", undefined, {
|
||||
baseUrl,
|
||||
}),
|
||||
).rejects.toMatchObject({
|
||||
message: "Signal RPC returned malformed JSON (status 502)",
|
||||
cause: expect.any(SyntaxError),
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
thrown = error;
|
||||
}
|
||||
|
||||
expect(thrown).toBeInstanceOf(Error);
|
||||
if (!(thrown instanceof Error)) {
|
||||
throw new Error("expected malformed JSON request to throw an Error");
|
||||
}
|
||||
expect(thrown.message).toBe("Signal RPC returned malformed JSON (status 502)");
|
||||
expect(thrown.cause).toBeInstanceOf(SyntaxError);
|
||||
});
|
||||
|
||||
it("throws when RPC response envelope has neither result nor error", async () => {
|
||||
|
||||
@@ -136,6 +136,12 @@ describe("signalMessageActions", () => {
|
||||
|
||||
for (const testCase of cases) {
|
||||
sendReactionSignalMock.mockClear();
|
||||
const expectedOptions = testCase.expectedOptions as {
|
||||
accountId?: string;
|
||||
groupId?: string;
|
||||
targetAuthor?: string;
|
||||
targetAuthorUuid?: string;
|
||||
};
|
||||
await signalMessageActions.handleAction?.({
|
||||
channel: "signal",
|
||||
action: "react",
|
||||
@@ -149,10 +155,13 @@ describe("signalMessageActions", () => {
|
||||
testCase.expectedRecipient,
|
||||
testCase.expectedTimestamp,
|
||||
testCase.expectedEmoji,
|
||||
expect.objectContaining({
|
||||
{
|
||||
cfg: testCase.cfg,
|
||||
...testCase.expectedOptions,
|
||||
}),
|
||||
accountId: expectedOptions.accountId,
|
||||
groupId: expectedOptions.groupId,
|
||||
targetAuthor: expectedOptions.targetAuthor,
|
||||
targetAuthorUuid: expectedOptions.targetAuthorUuid,
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user