driver to user id
This commit is contained in:
@@ -6,7 +6,7 @@ import request from 'supertest';
|
||||
import { Mock, vi } from 'vitest';
|
||||
import { AuthController } from './AuthController';
|
||||
import { AuthService } from './AuthService';
|
||||
import { AuthSessionDTO, LoginParamsDTO, SignupParamsDTO } from './dtos/AuthDto';
|
||||
import { AuthSessionDTO, LoginParamsDTO, SignupParamsDTO, SignupSponsorParamsDTO } from './dtos/AuthDto';
|
||||
import type { CommandResultDTO } from './presenters/CommandResultPresenter';
|
||||
import { AuthenticationGuard } from './AuthenticationGuard';
|
||||
import { AuthorizationGuard } from './AuthorizationGuard';
|
||||
@@ -21,6 +21,7 @@ describe('AuthController', () => {
|
||||
beforeEach(() => {
|
||||
service = {
|
||||
signupWithEmail: vi.fn(),
|
||||
signupSponsor: vi.fn(),
|
||||
loginWithEmail: vi.fn(),
|
||||
getCurrentSession: vi.fn(),
|
||||
logout: vi.fn(),
|
||||
@@ -56,6 +57,32 @@ describe('AuthController', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('signupSponsor', () => {
|
||||
it('should call service.signupSponsor and return session DTO', async () => {
|
||||
const params: SignupSponsorParamsDTO = {
|
||||
email: 'sponsor@example.com',
|
||||
password: 'Password123',
|
||||
displayName: 'John Doe',
|
||||
companyName: 'Acme Racing Co.',
|
||||
};
|
||||
const session: AuthSessionDTO = {
|
||||
token: 'token123',
|
||||
user: {
|
||||
userId: 'user1',
|
||||
email: 'sponsor@example.com',
|
||||
displayName: 'John Doe',
|
||||
companyId: 'company-123',
|
||||
},
|
||||
};
|
||||
(service.signupSponsor as Mock).mockResolvedValue(session);
|
||||
|
||||
const result = await controller.signupSponsor(params);
|
||||
|
||||
expect(service.signupSponsor).toHaveBeenCalledWith(params);
|
||||
expect(result).toEqual(session);
|
||||
});
|
||||
});
|
||||
|
||||
describe('login', () => {
|
||||
it('should call service.loginWithEmail and return session DTO', async () => {
|
||||
const params: LoginParamsDTO = {
|
||||
@@ -155,6 +182,7 @@ describe('AuthController', () => {
|
||||
getCurrentSession: vi.fn(async () => null),
|
||||
loginWithEmail: vi.fn(),
|
||||
signupWithEmail: vi.fn(),
|
||||
signupSponsor: vi.fn(),
|
||||
logout: vi.fn(),
|
||||
startIracingAuth: vi.fn(),
|
||||
iracingCallback: vi.fn(),
|
||||
|
||||
Reference in New Issue
Block a user