(session: ResolvedAuthSession, fn: () => T)
| 60 | } |
| 61 | |
| 62 | function 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 | |
| 82 | afterEach(() => { |
| 83 | globalThis.MACRO = originalMacro |
no test coverage detected