Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit dab4e2c

Browse files
committed
test(oauth): restoring mocked global
1 parent 4f62b40 commit dab4e2c

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/services/mcp/utils/__tests__/oauth.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, vi, beforeEach } from "vitest"
1+
import { describe, it, expect, vi, beforeEach, afterAll } from "vitest"
22

33
// Mock the SDK's discoverOAuthProtectedResourceMetadata
44
vi.mock("@modelcontextprotocol/sdk/client/auth.js", () => ({
@@ -9,13 +9,18 @@ import { discoverOAuthProtectedResourceMetadata } from "@modelcontextprotocol/sd
99
import { fetchOAuthAuthServerMetadata } from "../oauth"
1010

1111
const mockFetch = vi.fn()
12+
const originalFetch = global.fetch
1213
global.fetch = mockFetch
1314

1415
describe("fetchOAuthAuthServerMetadata", () => {
1516
beforeEach(() => {
1617
vi.clearAllMocks()
1718
})
1819

20+
afterAll(() => {
21+
global.fetch = originalFetch
22+
})
23+
1924
it("returns null when resource metadata has no authorization_servers", async () => {
2025
;(discoverOAuthProtectedResourceMetadata as any).mockResolvedValue({
2126
resource: "https://example.com/",

0 commit comments

Comments
 (0)