import { PenaltyValue } from './PenaltyValue';
import { RacingDomainValidationError } from '../../errors/RacingDomainError';

describe('PenaltyValue', () => {
  describe('create', () => {
    it('should create a PenaltyValue with positive integer', () => {
      const value = PenaltyValue.create(5);
      expect(value.toNumber()).toBe(5);
    });

    it('should throw error for zero', () => {
      expect(() => PenaltyValue.create(0)).toThrow(RacingDomainValidationError);
    });

    it('should throw error for negative number', () => {
      expect(() => PenaltyValue.create(-1)).toThrow(RacingDomainValidationError);
    });

    it('should throw error for non-integer', () => {
      expect(() => PenaltyValue.create(5.5)).toThrow(RacingDomainValidationError);
    });
  });

  describe('equals', () => {
    it('should return true for equal values', () => {
      const value1 = PenaltyValue.create(5);
      const value2 = PenaltyValue.create(5);
      expect(value1.equals(value2)).toBe(true);
    });

    it('should return false for different values', () => {
      const value1 = PenaltyValue.create(5);
      const value2 = PenaltyValue.create(10);
      expect(value1.equals(value2)).toBe(false);
    });
  });
});