import { describe, expect, it } from "vitest";
import {
  claimDateTimeValueToInputString,
  dateTimeInputToUnixSeconds,
  unixSecondsToDateTimeInput,
} from "./rpClaimDateTime";

describe("rpClaimDateTime", () => {
  it("converts date and datetime input in a selected timezone to Unix seconds", () => {
    expect(dateTimeInputToUnixSeconds("2026-06-10", "date", "Asia/Seoul")).toBe(
      1781017200,
    );
    expect(
      dateTimeInputToUnixSeconds("2026-06-09T10:30", "datetime", "Asia/Seoul"),
    ).toBe(1780968600);
  });

  it("formats stored Unix seconds for the selected timezone", () => {
    expect(unixSecondsToDateTimeInput(1781017200, "date", "Asia/Seoul")).toBe(
      "2026-06-10",
    );
    expect(
      unixSecondsToDateTimeInput(1780968600, "datetime", "Asia/Seoul"),
    ).toBe("2026-06-09T10:30");
  });

  it("uses Unix seconds values when hydrating date inputs", () => {
    expect(
      claimDateTimeValueToInputString(1780968600, "", "datetime", "Asia/Seoul"),
    ).toBe("2026-06-09T10:30");
  });
});
