test: guard slack probe mock calls

This commit is contained in:
Peter Steinberger
2026-05-12 00:48:07 +01:00
parent 2b202ffe7c
commit 9682e7a034

View File

@@ -13,6 +13,14 @@ vi.mock("openclaw/plugin-sdk/text-utility-runtime", () => ({
withTimeout: withTimeoutMock,
}));
function requireFirstTimeoutCall() {
const [call] = withTimeoutMock.mock.calls;
if (!call) {
throw new Error("expected withTimeout call");
}
return call;
}
describe("probeSlack", () => {
beforeEach(() => {
authTestMock.mockReset();
@@ -46,8 +54,9 @@ describe("probeSlack", () => {
});
expect(createSlackWebClientMock).toHaveBeenCalledWith("xoxb-test");
expect(withTimeoutMock).toHaveBeenCalledTimes(1);
expect(withTimeoutMock.mock.calls[0]?.[0]).toBeInstanceOf(Promise);
expect(withTimeoutMock.mock.calls[0]?.[1]).toBe(2500);
const [promise, timeoutMs] = requireFirstTimeoutCall();
expect(promise).toBeInstanceOf(Promise);
expect(timeoutMs).toBe(2500);
});
it("keeps optional auth metadata fields undefined when Slack omits them", async () => {