mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: guard channel provider helpers
This commit is contained in:
@@ -86,7 +86,9 @@ async function waitForFakeSocket(): Promise<FakeWebSocketInstance> {
|
||||
let socket: FakeWebSocketInstance | undefined;
|
||||
await vi.waitFor(() => {
|
||||
socket = FakeWebSocket.instances[0];
|
||||
expect(socket).toBeDefined();
|
||||
if (!socket) {
|
||||
throw new Error("expected session to create a websocket");
|
||||
}
|
||||
});
|
||||
if (!socket) {
|
||||
throw new Error("expected session to create a websocket");
|
||||
|
||||
@@ -79,9 +79,11 @@ function statusPatches(source: MockCallSource): Record<string, unknown>[] {
|
||||
}
|
||||
|
||||
function expectPollingConnectedPatch(patch: Record<string, unknown> | undefined): void {
|
||||
expect(patch).toBeDefined();
|
||||
expect(patch?.connected).toBe(true);
|
||||
expect(patch?.mode).toBe("polling");
|
||||
if (!patch) {
|
||||
throw new Error("Expected polling connected patch");
|
||||
}
|
||||
expect(patch.connected).toBe(true);
|
||||
expect(patch.mode).toBe("polling");
|
||||
}
|
||||
|
||||
function makeBot() {
|
||||
|
||||
@@ -95,8 +95,11 @@ function mockStringMessages(mocked: unknown): string[] {
|
||||
|
||||
function mockCallArg(mocked: unknown, callIndex: number, argIndex: number): unknown {
|
||||
const calls = (mocked as { mock?: { calls?: unknown[][] } }).mock?.calls;
|
||||
expect(calls?.[callIndex]).toBeDefined();
|
||||
return calls?.[callIndex]?.[argIndex];
|
||||
const call = calls?.[callIndex];
|
||||
if (!call) {
|
||||
throw new Error(`Expected mock call at index ${callIndex}`);
|
||||
}
|
||||
return call[argIndex];
|
||||
}
|
||||
|
||||
async function expectPathMissing(targetPath: string): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user