mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-14 11:30:41 +00:00
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("@slack/web-api", () => {
|
|
const WebClient = vi.fn(function WebClientMock(
|
|
this: Record<string, unknown>,
|
|
token: string,
|
|
options?: Record<string, unknown>,
|
|
) {
|
|
this.token = token;
|
|
this.options = options;
|
|
});
|
|
return { WebClient };
|
|
});
|
|
|
|
const slackWebApi = await import("@slack/web-api");
|
|
const { createSlackWebClient, resolveSlackWebClientOptions, SLACK_DEFAULT_RETRY_OPTIONS } =
|
|
await import("./client.js");
|
|
|
|
const WebClient = slackWebApi.WebClient as unknown as ReturnType<typeof vi.fn>;
|
|
|
|
describe("slack web client config", () => {
|
|
it("applies the default retry config when none is provided", () => {
|
|
const options = resolveSlackWebClientOptions();
|
|
|
|
expect(options.retryConfig).toEqual(SLACK_DEFAULT_RETRY_OPTIONS);
|
|
});
|
|
|
|
it("respects explicit retry config overrides", () => {
|
|
const customRetry = { retries: 0 };
|
|
const options = resolveSlackWebClientOptions({ retryConfig: customRetry });
|
|
|
|
expect(options.retryConfig).toBe(customRetry);
|
|
});
|
|
|
|
it("passes merged options into WebClient", () => {
|
|
createSlackWebClient("xoxb-test", { timeout: 1234 });
|
|
|
|
expect(WebClient).toHaveBeenCalledWith(
|
|
"xoxb-test",
|
|
expect.objectContaining({
|
|
timeout: 1234,
|
|
retryConfig: SLACK_DEFAULT_RETRY_OPTIONS,
|
|
}),
|
|
);
|
|
});
|
|
});
|