Download packages/app/src/context/global-sync/mcp.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/context/global-sync/mcp.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/context/global-sync/mcp.test.ts
-
curl -L -o mcp.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/context/global-sync/mcp.test.ts
1.43 kB
| import { describe, expect, test } from "bun:test" | |
| import { toggleMcp } from "./mcp" | |
| describe("toggleMcp", () => { | |
| test("runs the status action before refreshing the owning query", async () => { | |
| const calls: string[] = [] | |
| const input = (status: "connected" | "needs_auth" | "disabled") => ({ | |
| status, | |
| connect: async () => { | |
| calls.push("connect") | |
| }, | |
| disconnect: async () => { | |
| calls.push("disconnect") | |
| }, | |
| authenticate: async () => { | |
| calls.push("authenticate") | |
| }, | |
| refresh: async () => { | |
| calls.push("refresh") | |
| }, | |
| }) | |
| await toggleMcp(input("connected")) | |
| expect(calls).toEqual(["disconnect", "refresh"]) | |
| calls.length = 0 | |
| await toggleMcp(input("needs_auth")) | |
| expect(calls).toEqual(["authenticate", "refresh"]) | |
| calls.length = 0 | |
| await toggleMcp(input("disabled")) | |
| expect(calls).toEqual(["connect", "refresh"]) | |
| }) | |
| test("does not toggle a server while its connection is pending", async () => { | |
| const calls: string[] = [] | |
| await toggleMcp({ | |
| status: "pending", | |
| connect: async () => { | |
| calls.push("connect") | |
| }, | |
| disconnect: async () => { | |
| calls.push("disconnect") | |
| }, | |
| authenticate: async () => { | |
| calls.push("authenticate") | |
| }, | |
| refresh: async () => { | |
| calls.push("refresh") | |
| }, | |
| }) | |
| expect(calls).toEqual([]) | |
| }) | |
| }) | |