( session: ResolvedAuthSession, fn: () => T, )
| 125 | } |
| 126 | |
| 127 | function withMockCurrentSession<T>( |
| 128 | session: ResolvedAuthSession, |
| 129 | fn: () => T, |
| 130 | ): T { |
| 131 | const runtime = getAuthRuntime() |
| 132 | const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime) |
| 133 | ;( |
| 134 | runtime as { |
| 135 | getCurrentSession: typeof runtime.getCurrentSession |
| 136 | } |
| 137 | ).getCurrentSession = () => session |
| 138 | |
| 139 | try { |
| 140 | return fn() |
| 141 | } finally { |
| 142 | ;( |
| 143 | runtime as { |
| 144 | getCurrentSession: typeof runtime.getCurrentSession |
| 145 | } |
| 146 | ).getCurrentSession = originalGetCurrentSession |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | beforeAll(async () => { |
| 151 | tempConfigDir = await mkdtemp(join(tmpdir(), 'ncode-user-test-')) |
no test coverage detected