Skip to content

Commit 4a43d44

Browse files
committed
fix: orgs test
1 parent a918832 commit 4a43d44

File tree

3 files changed

+26
-34
lines changed

3 files changed

+26
-34
lines changed

tests/integration/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function setupIntegrationTest(): IntegrationTest {
3737

3838
let randomDbName: string;
3939

40-
beforeEach(async () => {
40+
beforeAll(async () => {
4141
const clientTransport = new InMemoryTransport();
4242
const serverTransport = new InMemoryTransport();
4343

tests/integration/tools/atlas/atlasHelpers.ts

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,22 @@ import { Session } from "../../../../src/session.js";
66

77
export type IntegrationTestFunction = (integration: IntegrationTest) => void;
88

9-
export function describeTest(name: number | string | Function | jest.FunctionLike, fn: IntegrationTestFunction) {
10-
return describe("test", () => {
11-
const integration = setupIntegrationTest();
12-
describe(name, () => {
13-
fn(integration);
14-
});
15-
});
16-
}
17-
189
export function sleep(ms: number) {
1910
return new Promise((resolve) => setTimeout(resolve, ms));
2011
}
2112

2213
export function describeAtlas(name: number | string | Function | jest.FunctionLike, fn: IntegrationTestFunction) {
23-
if (!process.env.MDB_MCP_API_CLIENT_ID?.length || !process.env.MDB_MCP_API_CLIENT_SECRET?.length) {
24-
return describe.skip("atlas", () => {
25-
describeTest(name, fn);
14+
const testDefinition = () => {
15+
const integration = setupIntegrationTest();
16+
describe(name, () => {
17+
fn(integration);
2618
});
19+
};
20+
21+
if (!process.env.MDB_MCP_API_CLIENT_ID?.length || !process.env.MDB_MCP_API_CLIENT_SECRET?.length) {
22+
return describe.skip("atlas", testDefinition);
2723
}
28-
return describe("atlas", () => {
29-
describeTest(name, fn);
30-
});
24+
return describe("atlas", testDefinition);
3125
}
3226

3327
interface ProjectTestArgs {

tests/integration/tools/atlas/orgs.test.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,23 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
22
import { setupIntegrationTest } from "../../helpers.js";
33
import { parseTable, describeAtlas } from "./atlasHelpers.js";
44

5-
describeAtlas("orgs", () => {
6-
setupIntegrationTest("tests", (integration) => {
7-
describe("atlas-list-orgs", () => {
8-
it("should have correct metadata", async () => {
9-
const { tools } = await integration.mcpClient().listTools();
10-
const listOrgs = tools.find((tool) => tool.name === "atlas-list-orgs");
11-
expect(listOrgs).toBeDefined();
12-
});
5+
describeAtlas("orgs", (integration) => {
6+
describe("atlas-list-orgs", () => {
7+
it("should have correct metadata", async () => {
8+
const { tools } = await integration.mcpClient().listTools();
9+
const listOrgs = tools.find((tool) => tool.name === "atlas-list-orgs");
10+
expect(listOrgs).toBeDefined();
11+
});
1312

14-
it("returns org names", async () => {
15-
const response = (await integration
16-
.mcpClient()
17-
.callTool({ name: "atlas-list-orgs", arguments: {} })) as CallToolResult;
18-
expect(response.content).toBeArray();
19-
expect(response.content).toHaveLength(1);
20-
const data = parseTable(response.content[0].text as string);
21-
expect(data).toHaveLength(1);
22-
expect(data[0]["Organization Name"]).toEqual("MongoDB MCP Test");
23-
});
13+
it("returns org names", async () => {
14+
const response = (await integration
15+
.mcpClient()
16+
.callTool({ name: "atlas-list-orgs", arguments: {} })) as CallToolResult;
17+
expect(response.content).toBeArray();
18+
expect(response.content).toHaveLength(1);
19+
const data = parseTable(response.content[0].text as string);
20+
expect(data).toHaveLength(1);
21+
expect(data[0]["Organization Name"]).toEqual("MongoDB MCP Test");
2422
});
2523
});
2624
});

0 commit comments

Comments
 (0)