import { Test, TestingModule } from '@nestjs/testing';
import { AuthController } from './auth.controller';
import { AuthService } from './auth.service';
import { CreateUserDto } from '../dto/create-user.dto';

describe('AuthController', () => {
  let controller: AuthController;
  let authService: AuthService;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      controllers: [AuthController],
      providers: [
        {
          provide: AuthService,
          useValue: {
            createUser: jest.fn(),
          },
        },
      ],
    }).compile();

    controller = module.get<AuthController>(AuthController);
    authService = module.get<AuthService>(AuthService);
  });

  describe('register', () => {
    it('should call authService.createUser with CreateUserDto', async () => {
      const createUserDto: CreateUserDto = {
        name: 'testuser',
        password: 'password123',
        email: 'test@example.com',
      };

      await controller.register(createUserDto);

      expect(authService.createUser).toHaveBeenCalledWith(createUserDto);
    });
  });
});
