import { AuthSessionController } from './auth-session.controller'; describe('AuthSessionController', () => { it('POST /auth/session exchanges the authorization code via the token exchange service', async () => { const tokenExchange = { exchangeAuthorizationCode: jest .fn() .mockResolvedValue({ accessToken: 'at-1', expiresIn: 3600 }), }; const controller = new AuthSessionController(tokenExchange as never); const dto = { code: 'code-1', codeVerifier: 'verifier-1', redirectUri: 'http://localhost:4200/auth/callback', }; await expect(controller.createSession(dto)).resolves.toEqual({ accessToken: 'at-1', expiresIn: 3600, }); expect(tokenExchange.exchangeAuthorizationCode).toHaveBeenCalledWith(dto); }); });