AkurAI Build
Menu

popagent

public

Latest change 6edc7e928c57dab23c0973ed3f7ee70b3ebb72d5 - Initial popagent baseline by AkurAI Build

import { describe, expect, test } from "bun:test";
import { describeSchedule, scheduleCron } from "./schedules";

describe("schedule recurrence", () => {
  test("builds daily, weekday, and weekly expressions at the chosen local time", () => {
    expect(scheduleCron("daily", "08:30", "1")).toBe("30 8 * * *");
    expect(scheduleCron("weekdays", "17:05", "1")).toBe("5 17 * * 1-5");
    expect(scheduleCron("weekly", "09:15", "3")).toBe("15 9 * * 3");
  });

  test("describes supported expressions without a timezone", () => {
    expect(describeSchedule("30 8 * * *")).toMatch(/^Daily at /);
    expect(describeSchedule("15 9 * * 3")).toMatch(/^Wednesdays at /);
  });

  test("rejects invalid times", () => {
    expect(() => scheduleCron("daily", "25:00", "1")).toThrow("Invalid schedule time");
  });
});