( session: ResolvedAuthSession, fn: () => T, )
| 82 | } |
| 83 | |
| 84 | function withMockCurrentSession<T>( |
| 85 | session: ResolvedAuthSession, |
| 86 | fn: () => T, |
| 87 | ): T { |
| 88 | const runtime = getAuthRuntime() |
| 89 | const originalGetCurrentSession = runtime.getCurrentSession.bind(runtime) |
| 90 | ;( |
| 91 | runtime as { |
| 92 | getCurrentSession: typeof runtime.getCurrentSession |
| 93 | } |
| 94 | ).getCurrentSession = () => session |
| 95 | |
| 96 | try { |
| 97 | return fn() |
| 98 | } finally { |
| 99 | ;( |
| 100 | runtime as { |
| 101 | getCurrentSession: typeof runtime.getCurrentSession |
| 102 | } |
| 103 | ).getCurrentSession = originalGetCurrentSession |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | beforeEach(() => { |
| 108 | process.env.CLAUDE_CODE_ENTRYPOINT = 'cli' |
no test coverage detected