import { UserId } from '../../../src/domain/value-objects/user-id.vo';

describe('UserId Value Object', () => {
  describe('create', () => {
    it('should create UserId from bigint', () => {
      const userId = UserId.create(123n);
      expect(userId.value).toBe(123n);
    });

    it('should create UserId from string', () => {
      const userId = UserId.create('456');
      expect(userId.value).toBe(456n);
    });

    it('should create UserId from number', () => {
      const userId = UserId.create(789);
      expect(userId.value).toBe(789n);
    });

    it('should throw error for zero value', () => {
      expect(() => UserId.create(0n)).toThrow('用户ID必须大于0');
    });

    it('should throw error for negative value', () => {
      expect(() => UserId.create(-1n)).toThrow('用户ID必须大于0');
    });
  });

  describe('equals', () => {
    it('should return true for equal values', () => {
      const userId1 = UserId.create(123n);
      const userId2 = UserId.create(123n);
      expect(userId1.equals(userId2)).toBe(true);
    });

    it('should return false for different values', () => {
      const userId1 = UserId.create(123n);
      const userId2 = UserId.create(456n);
      expect(userId1.equals(userId2)).toBe(false);
    });
  });

  describe('toString', () => {
    it('should return string representation', () => {
      const userId = UserId.create(123n);
      expect(userId.toString()).toBe('123');
    });
  });
});
