import { AnalyticsEntityId } from '@core/analytics/domain/value-objects/AnalyticsEntityId';

describe('AnalyticsEntityId', () => {
  it('creates a valid AnalyticsEntityId from a non-empty string', () => {
    const id = AnalyticsEntityId.create('entity_123');

    expect(id.value).toBe('entity_123');
  });

  it('trims whitespace from the raw value', () => {
    const id = AnalyticsEntityId.create('   entity_456   ');

    expect(id.value).toBe('entity_456');
  });

  it('throws for empty or whitespace-only strings', () => {
    expect(() => AnalyticsEntityId.create('')).toThrow(Error);
    expect(() => AnalyticsEntityId.create('   ')).toThrow(Error);
  });

  it('compares equality based on underlying value', () => {
    const a = AnalyticsEntityId.create('entity_1');
    const b = AnalyticsEntityId.create('entity_1');
    const c = AnalyticsEntityId.create('entity_2');

    expect(a.equals(b)).toBe(true);
    expect(a.equals(c)).toBe(false);
  });
});