From f56f0aa93d5b1535f64200bc8234a67e79623511 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 1 May 2025 13:39:53 +0530 Subject: [PATCH] add test --- core/context/mcp/MCPConnection.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/context/mcp/MCPConnection.test.ts b/core/context/mcp/MCPConnection.test.ts index 3e22e5f8e..4b5ccd2a0 100644 --- a/core/context/mcp/MCPConnection.test.ts +++ b/core/context/mcp/MCPConnection.test.ts @@ -151,6 +151,21 @@ describe("MCPConnection", () => { expect(mockConnect).toHaveBeenCalled(); }); + it('should handle custom connection timeout', async () => { + const conn = new MCPConnection({ ...options, timeout: 11 }); + const mockConnect = jest + .spyOn(Client.prototype, "connect") + .mockImplementation( + () => new Promise((resolve) => setTimeout(resolve, 10)), + ); + + const abortController = new AbortController(); + await conn.connectClient(false, abortController.signal); + + expect(conn.status).toBe("connected"); + expect(mockConnect).toHaveBeenCalled(); + }); + it("should handle connection timeout", async () => { const conn = new MCPConnection({ ...options, timeout: 1 }); const mockConnect = jest