import { describe, it, expect } from 'vitest';
import { ValueObject } from '../value-object';

class TestVO extends ValueObject<{ value: string }> {
  get value(): string {
    return this.props.value;
  }
}

describe('ValueObject', () => {
  it('should be immutable', () => {
    const vo = new TestVO({ value: 'hello' });
    expect(() => {
      (vo as any).props.value = 'changed';
    }).toThrow();
  });

  it('should be equal when props match', () => {
    const a = new TestVO({ value: 'same' });
    const b = new TestVO({ value: 'same' });
    expect(a.equals(b)).toBe(true);
  });

  it('should not be equal when props differ', () => {
    const a = new TestVO({ value: 'one' });
    const b = new TestVO({ value: 'two' });
    expect(a.equals(b)).toBe(false);
  });

  it('should not be equal to null/undefined', () => {
    const vo = new TestVO({ value: 'x' });
    expect(vo.equals(null as any)).toBe(false);
    expect(vo.equals(undefined as any)).toBe(false);
  });
});
