test: guard mattermost channel mock calls

This commit is contained in:
Peter Steinberger
2026-05-12 00:42:28 +01:00
parent ac92277066
commit 277ede4b1c

View File

@@ -105,7 +105,11 @@ function createMattermostActionContext(
function expectSingleMattermostSend(to: string, text: string): Record<string, unknown> {
expect(sendMessageMattermostMock).toHaveBeenCalledTimes(1);
const [actualTo, actualText, options] = sendMessageMattermostMock.mock.calls[0] ?? [];
const [call] = sendMessageMattermostMock.mock.calls;
if (!call) {
throw new Error("expected Mattermost send call");
}
const [actualTo, actualText, options] = call;
expect(actualTo).toBe(to);
expect(actualText).toBe(text);
if (!options || typeof options !== "object" || Array.isArray(options)) {