mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-21 16:41:56 +00:00
fix(test): annotate mock web listener return type
This commit is contained in:
@@ -6,7 +6,7 @@ import { afterAll, afterEach, beforeAll, beforeEach, vi } from "vitest";
|
||||
import { resetInboundDedupe } from "../auto-reply/reply/inbound-dedupe.js";
|
||||
import * as ssrf from "../infra/net/ssrf.js";
|
||||
import { resetLogger, setLoggerOverride } from "../logging.js";
|
||||
import type { WebInboundMessage } from "./inbound.js";
|
||||
import type { WebInboundMessage, WebListenerCloseReason } from "./inbound.js";
|
||||
import {
|
||||
resetBaileysMocks as _resetBaileysMocks,
|
||||
resetLoadConfigMock as _resetLoadConfigMock,
|
||||
@@ -17,6 +17,15 @@ export { resetBaileysMocks, resetLoadConfigMock, setLoadConfigMock } from "./tes
|
||||
// Avoid exporting inferred vitest mock types (TS2742 under pnpm + d.ts emit).
|
||||
// oxlint-disable-next-line typescript/no-explicit-any
|
||||
type AnyExport = any;
|
||||
type MockWebListener = {
|
||||
close: () => Promise<void>;
|
||||
onClose: Promise<WebListenerCloseReason>;
|
||||
signalClose: () => void;
|
||||
sendMessage: () => Promise<{ messageId: string }>;
|
||||
sendPoll: () => Promise<{ messageId: string }>;
|
||||
sendReaction: () => Promise<void>;
|
||||
sendComposingTo: () => Promise<void>;
|
||||
};
|
||||
|
||||
export const TEST_NET_IP = "203.0.113.10";
|
||||
|
||||
@@ -162,10 +171,10 @@ export function createWebListenerFactoryCapture(): AnyExport {
|
||||
};
|
||||
}
|
||||
|
||||
export function createMockWebListener() {
|
||||
export function createMockWebListener(): MockWebListener {
|
||||
return {
|
||||
close: vi.fn(async () => undefined),
|
||||
onClose: new Promise<import("./inbound.js").WebListenerCloseReason>(() => {}),
|
||||
onClose: new Promise<WebListenerCloseReason>(() => {}),
|
||||
signalClose: vi.fn(),
|
||||
sendMessage: vi.fn(async () => ({ messageId: "msg-1" })),
|
||||
sendPoll: vi.fn(async () => ({ messageId: "poll-1" })),
|
||||
|
||||
Reference in New Issue
Block a user