MCPcopy Index your code
hub / github.com/MiniMax-AI/cli / mockDeviceCodeFlow

Function mockDeviceCodeFlow

test/auth/oauth.test.ts:79–94  ·  view source on GitHub ↗

* Convenience: create a two-phase mock (device/code → token polling). * The first matching request returns a device-code response; all subsequent * requests return token responses.

(
  deviceOverrides?: Record<string, unknown>,
  tokenOverrides?: Record<string, unknown>,
)

Source from the content-addressed store, hash-verified

77 * requests return token responses.
78 */
79function mockDeviceCodeFlow(
80 deviceOverrides?: Record<string, unknown>,
81 tokenOverrides?: Record<string, unknown>,
82): FetchMock {
83 let first = true;
84 return (_url: string, opts?: RequestInit) => {
85 if (first) {
86 first = false;
87 const body = opts?.body instanceof URLSearchParams
88 ? opts.body
89 : new URLSearchParams(String(opts?.body ?? ''));
90 return Promise.resolve(deviceCodeResponse(body, deviceOverrides));
91 }
92 return Promise.resolve(tokenResponse(tokenOverrides));
93 };
94}
95
96const originalFetch = globalThis.fetch;
97

Callers

nothing calls this directly

Calls 3

deviceCodeResponseFunction · 0.85
tokenResponseFunction · 0.85
resolveMethod · 0.80

Tested by

no test coverage detected