MCPcopy Create free account
hub / github.com/Noumena-Network/code / withMockCurrentSession

Function withMockCurrentSession

src/services/api/metricsOptOut.test.ts:187–208  ·  view source on GitHub ↗
(
  session: ResolvedAuthSession,
  fn: () => Promise<T> | T,
)

Source from the content-addressed store, hash-verified

185}
186
187async function withMockCurrentSession<T>(
188 session: ResolvedAuthSession,
189 fn: () => Promise<T> | T,
190): Promise<T> {
191 const runtime = getAuthRuntime()
192 const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime)
193 ;(
194 runtime as {
195 getCurrentSession: typeof runtime.getCurrentSession
196 }
197 ).getCurrentSession = () => session
198
199 try {
200 return await fn()
201 } finally {
202 ;(
203 runtime as {
204 getCurrentSession: typeof runtime.getCurrentSession
205 }
206 ).getCurrentSession = originalGetCurrentSession
207 }
208}
209
210async function waitUntil(
211 predicate: () => boolean,

Callers 1

Calls 1

getAuthRuntimeFunction · 0.85

Tested by

no test coverage detected