import { describe, expect, it } from "vitest";
import {
  buildMothershipWeekdayGrid,
  isMothershipDateSelectable,
} from "@/lib/mothership/weekday-date-picker";

describe("weekday-date-picker", () => {
  it("周六日不可选", () => {
    expect(isMothershipDateSelectable("2026-07-18", "2026-07-01")).toBe(false);
    expect(isMothershipDateSelectable("2026-07-19", "2026-07-01")).toBe(false);
    expect(isMothershipDateSelectable("2026-07-20", "2026-07-01")).toBe(true);
  });

  it("网格周末格子 disabled", () => {
    const cells = buildMothershipWeekdayGrid(2026, 6, "2026-07-20", "2026-07-01");
    const sat = cells.find((c) => c.inMonth && c.iso === "2026-07-18");
    const sun = cells.find((c) => c.inMonth && c.iso === "2026-07-19");
    const mon = cells.find((c) => c.inMonth && c.iso === "2026-07-20");
    expect(sat?.disabled).toBe(true);
    expect(sat?.isWeekend).toBe(true);
    expect(sun?.disabled).toBe(true);
    expect(mon?.disabled).toBe(false);
    expect(mon?.isSelected).toBe(true);
  });
});
