import { describe, it, expect } from "vitest";
import { RecordingJobQueue } from "@/instrumentation/recording-job-queue";

describe("RecordingJobQueue", () => {
  it("records every enqueue call", async () => {
    const queue = new RecordingJobQueue();
    const future = new Date("2030-01-01");
    await queue.enqueue("a.task", { x: 1 });
    await queue.enqueue("b.task", { y: 2 }, { runAt: future });
    expect(queue.enqueued).toEqual([
      { taskSlug: "a.task", input: { x: 1 }, options: undefined },
      { taskSlug: "b.task", input: { y: 2 }, options: { runAt: future } },
    ]);
  });

  it("returns a synthetic jobId per call", async () => {
    const queue = new RecordingJobQueue();
    const a = await queue.enqueue("a", {});
    const b = await queue.enqueue("b", {});
    expect(a.jobId).toBe("recording-1");
    expect(b.jobId).toBe("recording-2");
  });
});
