import { UTCDateValue } from "./UTCDateValue"; // Asegúrate de importar la clase adecuadamente

describe("UTCDateValue Value Object", () => {
  it("should create an instance with the current date", () => {
    const result = UTCDateValue.createCurrentDate();
    expect(result.isSuccess).toBe(true);

    const currentDate = result.object;

    expect(currentDate.isEmpty()).toBe(false);

    expect(currentDate.toString()).toMatch(/^\d{4}-\d{2}-\d{2}$/); // Verifica el formato 'YYYY-MM-DD'
  });

  it("should create an instance from a valid date string", () => {
    const validDateString = "1999-12-31";

    const result = UTCDateValue.create(validDateString);
    expect(result.isSuccess).toBe(true);

    const validDate = result.object;

    expect(validDate.isEmpty()).toBe(false);
    expect(validDate.toString()).toBe(validDateString);
  });

  it("should create an instance with an empty date string", () => {
    const result = UTCDateValue.create(null);

    expect(result.isSuccess).toBe(true);

    const emptyDate = result.object;

    expect(emptyDate.isEmpty()).toBe(true);
    expect(emptyDate.toString()).toBe("");
  });

  it("should create an instance with an empty date string", () => {
    const result = UTCDateValue.create(null);

    expect(result.isSuccess).toBe(true);

    const emptyDate = result.object;

    expect(emptyDate.isEmpty()).toBe(true);
    expect(emptyDate.value).toBe(null);
  });


  it("should be failure for an invalid date string (result)", () => {
    const invalidDateString = "2023-13-45"; // Fecha inválida
    const result = UTCDateValue.create(invalidDateString);
    expect(result.isFailure).toBe(true);
  });
});
