Skip to content

Commit 28d8b69

Browse files
committed
chore: add tests for the actual connection status
Also remove the code that forces the reconnection in the stdio transport test as it's not needed anymore.
1 parent 3f52815 commit 28d8b69

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

tests/integration/common/connectionManager.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ describeWithMongoDB("Connection Manager", (integration) => {
7878
it("should notify that it was disconnected before connecting", () => {
7979
expect(connectionManagerSpies["connection-closed"]).toHaveBeenCalled();
8080
});
81+
82+
it("should be marked explicitly as disconnected", () => {
83+
expect(connectionManager().currentConnectionState.tag).toEqual("disconnected");
84+
});
8185
});
8286

8387
describe("when reconnects", () => {
@@ -95,6 +99,10 @@ describeWithMongoDB("Connection Manager", (integration) => {
9599
it("should notify that it was connected again", () => {
96100
expect(connectionManagerSpies["connection-succeeded"]).toHaveBeenCalled();
97101
});
102+
103+
it("should be marked explicitly as connected", () => {
104+
expect(connectionManager().currentConnectionState.tag).toEqual("connected");
105+
});
98106
});
99107

100108
describe("when fails to connect to a new cluster", () => {
@@ -116,6 +124,10 @@ describeWithMongoDB("Connection Manager", (integration) => {
116124
it("should notify that it failed connecting", () => {
117125
expect(connectionManagerSpies["connection-errored"]).toHaveBeenCalled();
118126
});
127+
128+
it("should be marked explicitly as connected", () => {
129+
expect(connectionManager().currentConnectionState.tag).toEqual("errored");
130+
});
119131
});
120132
});
121133

tests/integration/transports/stdio.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ import { Client } from "@modelcontextprotocol/sdk/client/index.js";
44
import { describeWithMongoDB } from "../tools/mongodb/mongodbHelpers.js";
55

66
describeWithMongoDB("StdioRunner", (integration) => {
7-
beforeEach(() => {
8-
integration.mcpServer().userConfig.connectionString = integration.connectionString();
9-
integration.mcpServer().session.connectionManager.changeState("connection-succeeded", {
10-
tag: "connected",
11-
});
12-
});
13-
147
describe("client connects successfully", () => {
158
let client: Client;
169
let transport: StdioClientTransport;

0 commit comments

Comments
 (0)