import { describe, it, expect } from "vitest";
import { getWeekDateRange } from "./weekDateRange.js";

describe("getWeekDateRange", () => {
  it("returns Monday/Sunday for a mid-week date", () => {
    // 2026-04-15 is a Wednesday
    const result = getWeekDateRange("2026-04-15T10:00:00");
    expect(result.start).toBe("13.04.2026");
    expect(result.end).toBe("19.04.2026");
  });

  it("returns Monday/Sunday for a Sunday input", () => {
    const result = getWeekDateRange("2026-04-19T10:00:00");
    expect(result.start).toBe("13.04.2026");
    expect(result.end).toBe("19.04.2026");
  });

  it("returns Monday/Sunday for a Monday input", () => {
    const result = getWeekDateRange("2026-04-13T10:00:00");
    expect(result.start).toBe("13.04.2026");
    expect(result.end).toBe("19.04.2026");
  });

  it("returns empty strings for invalid input", () => {
    expect(getWeekDateRange("not-a-date")).toEqual({ start: "", end: "" });
  });

  it("returns empty strings for undefined input", () => {
    expect(getWeekDateRange(undefined)).toEqual({ start: "", end: "" });
  });
});
