Skip to content

Commit 46e2e5f

Browse files
committed
fix test
1 parent a34de86 commit 46e2e5f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tests/unit/accessListUtils.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import { ApiClient } from "../../src/common/atlas/apiClient.js";
33
import { ensureCurrentIpInAccessList } from "../../src/common/atlas/accessListUtils.js";
44
import { jest } from "@jest/globals";
5+
import { ApiClientError } from "../../src/common/atlas/apiClientError.js";
56

6-
describe("ensureCurrentIpInAccessList", () => {
7+
describe("accessListUtils", () => {
78
it("should add the current IP to the access list", async () => {
89
const apiClient = {
910
getIpInfo: jest.fn().mockResolvedValue({ currentIpv4Address: "127.0.0.1" } as never),
@@ -12,19 +13,30 @@ describe("ensureCurrentIpInAccessList", () => {
1213
await ensureCurrentIpInAccessList(apiClient, "projectId");
1314
expect(apiClient.createProjectIpAccessList).toHaveBeenCalledWith({
1415
params: { path: { groupId: "projectId" } },
15-
body: [{ groupId: "projectId", ipAddress: "127.0.0.1", comment: "Added by MCP pre-run access list helper" }],
16+
body: [
17+
{ groupId: "projectId", ipAddress: "127.0.0.1", comment: "Added by MCP pre-run access list helper" },
18+
],
1619
});
1720
});
1821

1922
it("should not fail if the current IP is already in the access list", async () => {
2023
const apiClient = {
2124
getIpInfo: jest.fn().mockResolvedValue({ currentIpv4Address: "127.0.0.1" } as never),
22-
createProjectIpAccessList: jest.fn().mockRejectedValue({ response: { status: 409 } } as never),
25+
createProjectIpAccessList: jest
26+
.fn()
27+
.mockRejectedValue(
28+
ApiClientError.fromError(
29+
{ status: 409, statusText: "Conflict" } as Response,
30+
{ message: "Conflict" } as never
31+
) as never
32+
),
2333
} as unknown as ApiClient;
2434
await ensureCurrentIpInAccessList(apiClient, "projectId");
2535
expect(apiClient.createProjectIpAccessList).toHaveBeenCalledWith({
2636
params: { path: { groupId: "projectId" } },
27-
body: [{ groupId: "projectId", ipAddress: "127.0.0.1", comment: "Added by MCP pre-run access list helper" }],
37+
body: [
38+
{ groupId: "projectId", ipAddress: "127.0.0.1", comment: "Added by MCP pre-run access list helper" },
39+
],
2840
});
2941
});
3042
});

0 commit comments

Comments
 (0)