import { ListUsersRequestDto } from './ListUsersRequestDto';

describe('ListUsersRequestDto', () => {
  describe('TDD - Test First', () => {
    it('should create valid DTO with all fields', () => {
      // Arrange & Act
      const dto = new ListUsersRequestDto();
      dto.role = 'admin';
      dto.status = 'active';
      dto.email = 'test@example.com';
      dto.search = 'test';
      dto.page = 2;
      dto.limit = 20;
      dto.sortBy = 'email';
      dto.sortDirection = 'desc';

      // Assert
      expect(dto.role).toBe('admin');
      expect(dto.status).toBe('active');
      expect(dto.email).toBe('test@example.com');
      expect(dto.search).toBe('test');
      expect(dto.page).toBe(2);
      expect(dto.limit).toBe(20);
      expect(dto.sortBy).toBe('email');
      expect(dto.sortDirection).toBe('desc');
    });

    it('should create DTO with optional fields undefined', () => {
      // Arrange & Act
      const dto = new ListUsersRequestDto();

      // Assert
      expect(dto.role).toBeUndefined();
      expect(dto.status).toBeUndefined();
      expect(dto.email).toBeUndefined();
      expect(dto.search).toBeUndefined();
      expect(dto.page).toBeUndefined();
      expect(dto.limit).toBeUndefined();
      expect(dto.sortBy).toBeUndefined();
      expect(dto.sortDirection).toBeUndefined();
    });

    it('should handle partial input', () => {
      // Arrange & Act
      const dto = new ListUsersRequestDto();
      dto.page = 1;
      dto.limit = 10;

      // Assert
      expect(dto.page).toBe(1);
      expect(dto.limit).toBe(10);
      expect(dto.role).toBeUndefined();
      expect(dto.status).toBeUndefined();
    });

    it('should accept string values for all fields', () => {
      // Arrange & Act
      const dto = new ListUsersRequestDto();
      dto.role = 'owner';
      dto.status = 'suspended';
      dto.email = 'suspended@example.com';
      dto.search = 'suspended';
      dto.page = 3;
      dto.limit = 50;
      dto.sortBy = 'displayName';
      dto.sortDirection = 'asc';

      // Assert
      expect(dto.role).toBe('owner');
      expect(dto.status).toBe('suspended');
      expect(dto.email).toBe('suspended@example.com');
      expect(dto.search).toBe('suspended');
      expect(dto.page).toBe(3);
      expect(dto.limit).toBe(50);
      expect(dto.sortBy).toBe('displayName');
      expect(dto.sortDirection).toBe('asc');
    });

    it('should handle numeric string values for pagination', () => {
      // Arrange & Act
      const dto = new ListUsersRequestDto();
      dto.page = '5' as never;
      dto.limit = '25' as never;

      // Assert - Should accept the values
      expect(dto.page).toBe('5');
      expect(dto.limit).toBe('25');
    });

    it('should handle empty string values', () => {
      // Arrange & Act
      const dto = new ListUsersRequestDto();
      dto.role = '';
      dto.search = '';

      // Assert
      expect(dto.role).toBe('');
      expect(dto.search).toBe('');
    });

    it('should handle special characters in search', () => {
      // Arrange & Act
      const dto = new ListUsersRequestDto();
      dto.search = 'test@example.com';

      // Assert
      expect(dto.search).toBe('test@example.com');
    });

    it('should handle unicode characters', () => {
      // Arrange & Act
      const dto = new ListUsersRequestDto();
      dto.search = 'tëst ñame';

      // Assert
      expect(dto.search).toBe('tëst ñame');
    });
  });
});