test: tighten signal action assertions

This commit is contained in:
Shakker
2026-05-10 18:06:34 +01:00
parent 2d5caecb61
commit 417e62abb8
2 changed files with 26 additions and 10 deletions

View File

@@ -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 () => {

View File

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