// packages/marketing-pages/src/events/handlers/on-auth-user-signed-up.handler.test.ts
import { describe, it, expect } from "vitest";
import { RecordingJobQueue } from "@repo/core-testing/instrumentation";
import { onAuthUserSignedUpHandler } from "@/events/handlers/on-auth-user-signed-up.handler";

describe("onAuthUserSignedUpHandler", () => {
  it("enqueues marketing-pages.send-welcome-email with userId + email", async () => {
    const queue = new RecordingJobQueue();
    const handler = onAuthUserSignedUpHandler(queue);

    await handler({
      userId: "u-42",
      email: "alice@example.com",
      signedUpAt: "2026-05-08T12:00:00.000Z",
    });

    expect(queue.enqueued).toHaveLength(1);
    expect(queue.enqueued[0]).toEqual(
      expect.objectContaining({
        taskSlug: "marketing-pages.send-welcome-email",
        input: { userId: "u-42", email: "alice@example.com" },
      }),
    );
  });
});
