import { describe, it, expect } from 'vitest';
import { Phone } from '../value-objects/phone.vo';

describe('Phone Value Object', () => {
  it('should create from valid Vietnam phone (0 prefix)', () => {
    const result = Phone.create('0912345678');
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe('+84912345678');
  });

  it('should create from valid Vietnam phone (+84 prefix)', () => {
    const result = Phone.create('+84912345678');
    expect(result.isOk).toBe(true);
    expect(result.unwrap().value).toBe('+84912345678');
  });

  it('should reject invalid phone', () => {
    const result = Phone.create('12345');
    expect(result.isErr).toBe(true);
    expect(result.unwrapErr()).toBe('Số điện thoại không hợp lệ');
  });

  it('should check equality after normalization', () => {
    const a = Phone.create('0912345678').unwrap();
    const b = Phone.create('+84912345678').unwrap();
    expect(a.equals(b)).toBe(true);
  });
});
