import assert from "node:assert/strict";
import test from "node:test";
import { computeDueCutoff } from "../lib/wecom-notifier-service.ts";

test("computeDueCutoff advances by dueDays and crosses month/year", () => {
  assert.equal(computeDueCutoff("2026-08-18", 3), "2026-08-21");
  assert.equal(computeDueCutoff("2026-08-30", 3), "2026-09-02");
  assert.equal(computeDueCutoff("2026-12-30", 3), "2027-01-02");
  assert.equal(computeDueCutoff("2026-08-18", 0), "2026-08-18");
  assert.equal(computeDueCutoff("2026-08-18", 10), "2026-08-28");
});

test("computeDueCutoff returns input unchanged when malformed", () => {
  assert.equal(computeDueCutoff("not-a-date", 3), "not-a-date");
});
