import { Name } from "./name";

describe("Name Value Object", () => {
  test("Debe crear un Name válido", () => {
    const nameResult = Name.create("John Doe");
    expect(nameResult.isSuccess).toBe(true);
    expect(nameResult.data.getValue()).toBe("John Doe");
  });

  test("Debe fallar si el nombre excede los 255 caracteres", () => {
    const longName = "A".repeat(256);
    const nameResult = Name.create(longName);
    expect(nameResult.isSuccess).toBe(false);
    expect(nameResult.error).toBeInstanceOf(Error);
  });

  test("Debe generar acrónimos correctamente", () => {
    expect(Name.generateAcronym("John Doe")).toBe("JDXX");
    expect(Name.generateAcronym("Alice Bob Charlie")).toBe("ABCX");
    expect(Name.generateAcronym("A B C D E")).toBe("ABCD");
    expect(Name.generateAcronym("SingleWord")).toBe("SXXX");
  });

  test("Debe obtener el acrónimo de una instancia de Name", () => {
    const name = Name.create("John Doe").data;
    expect(name.getAcronym()).toBe("JDXX");
  });
});
