import { describe, expect, it } from 'vitest';
import { RacingDomainValidationError } from '../../errors/RacingDomainError';
import { PrizeStatus } from './PrizeStatus';

describe('PrizeStatus', () => {
  describe('create', () => {
    it('should create a PrizeStatus with valid value', () => {
      const status = PrizeStatus.create('pending');
      expect(status.toString()).toBe('pending');
    });

    it('should create all valid statuses', () => {
      const validStatuses = ['pending', 'awarded', 'paid', 'cancelled'];

      validStatuses.forEach(statusValue => {
        const status = PrizeStatus.create(statusValue);
        expect(status.toString()).toBe(statusValue);
      });
    });

    it('should throw error for invalid status', () => {
      expect(() => PrizeStatus.create('invalid_status')).toThrow(RacingDomainValidationError);
    });

    it('should throw error for empty string', () => {
      expect(() => PrizeStatus.create('')).toThrow(RacingDomainValidationError);
    });
  });

  describe('equals', () => {
    it('should return true for equal statuses', () => {
      const status1 = PrizeStatus.create('pending');
      const status2 = PrizeStatus.create('pending');
      expect(status1.equals(status2)).toBe(true);
    });

    it('should return false for different statuses', () => {
      const status1 = PrizeStatus.create('pending');
      const status2 = PrizeStatus.create('awarded');
      expect(status1.equals(status2)).toBe(false);
    });
  });
});