import { LeadScore } from '../value-objects/lead-score.vo';

describe('LeadScore Value Object', () => {
  it('should create a valid lead score', () => {
    const result = LeadScore.create(75);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(75);
  });

  it('should accept minimum score of 0', () => {
    const result = LeadScore.create(0);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(0);
  });

  it('should accept maximum score of 100', () => {
    const result = LeadScore.create(100);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(100);
  });

  it('should reject negative score', () => {
    const result = LeadScore.create(-1);
    expect(result.isErr).toBe(true);
    expect(result.unwrapErr()).toBe('Điểm lead phải từ 0 đến 100');
  });

  it('should reject score above 100', () => {
    const result = LeadScore.create(101);
    expect(result.isErr).toBe(true);
    expect(result.unwrapErr()).toBe('Điểm lead phải từ 0 đến 100');
  });

  it('should accept decimal scores', () => {
    const result = LeadScore.create(50.5);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(50.5);
  });

  it('should accept boundary score of 1', () => {
    const result = LeadScore.create(1);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(1);
  });

  it('should accept boundary score of 99', () => {
    const result = LeadScore.create(99);
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe(99);
  });
});
