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

Function withMockCurrentSession

src/utils/logoV2Utils.auth.test.ts:62–80  ·  view source on GitHub ↗
(session: ResolvedAuthSession, fn: () => T)

Source from the content-addressed store, hash-verified

60}
61
62function withMockCurrentSession<T>(session: ResolvedAuthSession, fn: () => T): T {
63 const runtime = getAuthRuntime()
64 const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime)
65 ;(
66 runtime as {
67 getCurrentSession: typeof runtime.getCurrentSession
68 }
69 ).getCurrentSession = () => session
70
71 try {
72 return fn()
73 } finally {
74 ;(
75 runtime as {
76 getCurrentSession: typeof runtime.getCurrentSession
77 }
78 ).getCurrentSession = originalGetCurrentSession
79 }
80}
81
82afterEach(() => {
83 globalThis.MACRO = originalMacro

Callers 1

Calls 1

getAuthRuntimeFunction · 0.85

Tested by

no test coverage detected