import { GameKey } from './GameKey';
import { IdentityDomainValidationError } from '../errors/IdentityDomainError';

describe('GameKey', () => {
  describe('create', () => {
    it('should create valid game keys', () => {
      expect(GameKey.create('iracing').value).toBe('iracing');
      expect(GameKey.create('acc').value).toBe('acc');
      expect(GameKey.create('f1').value).toBe('f1');
    });

    it('should throw for invalid game key', () => {
      expect(() => GameKey.create('')).toThrow(IdentityDomainValidationError);
      expect(() => GameKey.create('  ')).toThrow(IdentityDomainValidationError);
      expect(() => GameKey.create('invalid game')).toThrow(IdentityDomainValidationError);
    });

    it('should trim whitespace', () => {
      const key = GameKey.create('  iracing  ');
      expect(key.value).toBe('iracing');
    });

    it('should accept lowercase', () => {
      const key = GameKey.create('iracing');
      expect(key.value).toBe('iracing');
    });
  });

  describe('equals', () => {
    it('should return true for same value', () => {
      const key1 = GameKey.create('iracing');
      const key2 = GameKey.create('iracing');
      expect(key1.equals(key2)).toBe(true);
    });

    it('should return false for different values', () => {
      const key1 = GameKey.create('iracing');
      const key2 = GameKey.create('acc');
      expect(key1.equals(key2)).toBe(false);
    });
  });

  describe('props', () => {
    it('should expose props correctly', () => {
      const key = GameKey.create('iracing');
      expect(key.props.value).toBe('iracing');
    });
  });

  describe('toString', () => {
    it('should return string representation', () => {
      const key = GameKey.create('iracing');
      expect(key.toString()).toBe('iracing');
    });
  });
});