import { ValuationEntity } from '../entities/valuation.entity';

describe('ValuationEntity', () => {
  const baseProps = {
    propertyId: 'prop-1',
    estimatedPrice: BigInt(5000000000),
    confidence: 0.85,
    pricePerM2: 50000000,
    comparables: [{ id: 'comp-1', price: 4800000000 }],
    features: { area: 100, bedrooms: 3 },
    modelVersion: 'v1',
  };

  it('createNew creates entity with all properties', () => {
    const entity = ValuationEntity.createNew(
      'val-1',
      baseProps.propertyId,
      baseProps.estimatedPrice,
      baseProps.confidence,
      baseProps.pricePerM2,
      baseProps.comparables,
      baseProps.features,
      baseProps.modelVersion,
    );

    expect(entity.id).toBe('val-1');
    expect(entity.propertyId).toBe('prop-1');
    expect(entity.estimatedPrice).toBe(BigInt(5000000000));
    expect(entity.confidence).toBe(0.85);
    expect(entity.pricePerM2).toBe(50000000);
    expect(entity.comparables).toEqual(baseProps.comparables);
    expect(entity.features).toEqual(baseProps.features);
    expect(entity.modelVersion).toBe('v1');
  });

  it('constructor sets all properties correctly', () => {
    const createdAt = new Date('2026-01-15');
    const entity = new ValuationEntity('val-2', baseProps, createdAt);

    expect(entity.id).toBe('val-2');
    expect(entity.propertyId).toBe('prop-1');
    expect(entity.estimatedPrice).toBe(BigInt(5000000000));
    expect(entity.confidence).toBe(0.85);
    expect(entity.pricePerM2).toBe(50000000);
    expect(entity.comparables).toEqual(baseProps.comparables);
    expect(entity.features).toEqual(baseProps.features);
    expect(entity.modelVersion).toBe('v1');
    expect(entity.createdAt).toBe(createdAt);
  });

  it('all getters return expected values', () => {
    const entity = new ValuationEntity('val-3', {
      propertyId: 'prop-99',
      estimatedPrice: BigInt(9999000000),
      confidence: 0.92,
      pricePerM2: 99000000,
      comparables: [],
      features: { location: 'central' },
      modelVersion: 'v2',
    });

    expect(entity.propertyId).toBe('prop-99');
    expect(entity.estimatedPrice).toBe(BigInt(9999000000));
    expect(entity.confidence).toBe(0.92);
    expect(entity.pricePerM2).toBe(99000000);
    expect(entity.comparables).toEqual([]);
    expect(entity.features).toEqual({ location: 'central' });
    expect(entity.modelVersion).toBe('v2');
  });
});
