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

Function withMockCurrentSession

src/utils/model/modelOptions.auth.test.ts:117–138  ·  view source on GitHub ↗
(
  session: ResolvedAuthSession,
  fn: () => T,
)

Source from the content-addressed store, hash-verified

115}
116
117function withMockCurrentSession<T>(
118 session: ResolvedAuthSession,
119 fn: () => T,
120): T {
121 const runtime = getAuthRuntime()
122 const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime)
123 ;(
124 runtime as {
125 getCurrentSession: typeof runtime.getCurrentSession
126 }
127 ).getCurrentSession = () => session
128
129 try {
130 return fn()
131 } finally {
132 ;(
133 runtime as {
134 getCurrentSession: typeof runtime.getCurrentSession
135 }
136 ).getCurrentSession = originalGetCurrentSession
137 }
138}
139
140afterEach(() => {
141 restoreEnv()

Callers 1

Calls 1

getAuthRuntimeFunction · 0.85

Tested by

no test coverage detected