import { describe, expect, it } from "vitest";
import { toUtcIso } from "../auditLabels";

describe("audit time formatter", () => {
  it("datetime-local转换为带Z的UTC ISO 8601", () => {
    const input = "2026-07-23T10:30";
    expect(toUtcIso(input)).toBe(new Date(input).toISOString());
    expect(toUtcIso(input)).toMatch(/Z$/);
  });

  it("不擅自改变半开区间结束时间", () => {
    const createdTo = "2026-08-01T00:00";
    expect(toUtcIso(createdTo)).toBe(new Date(createdTo).toISOString());
  });

  it("空值和无效值不产生未知参数", () => {
    expect(toUtcIso("")).toBeUndefined();
    expect(toUtcIso("not-a-date")).toBeUndefined();
  });
});

