( session: ResolvedAuthSession, fn: () => T, )
| 190 | } |
| 191 | |
| 192 | function withMockCurrentSession<T>( |
| 193 | session: ResolvedAuthSession, |
| 194 | fn: () => T, |
| 195 | ): T { |
| 196 | const runtime = getAuthRuntime() |
| 197 | const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime) |
| 198 | ;( |
| 199 | runtime as { |
| 200 | getCurrentSession: typeof runtime.getCurrentSession |
| 201 | } |
| 202 | ).getCurrentSession = () => session |
| 203 | |
| 204 | try { |
| 205 | return fn() |
| 206 | } finally { |
| 207 | ;( |
| 208 | runtime as { |
| 209 | getCurrentSession: typeof runtime.getCurrentSession |
| 210 | } |
| 211 | ).getCurrentSession = originalGetCurrentSession |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | beforeEach(async () => { |
| 216 | tempConfigDir = await mkdtemp(join(tmpdir(), 'ncode-errors-auth-test-')) |
no test coverage detected