import { describe, it, expect } from "vitest";
import { RecordingDataExport } from "./recording-data-export";

describe("RecordingDataExport", () => {
  it("records exportSubjectData calls", async () => {
    const exporter = new RecordingDataExport();
    await exporter.exportSubjectData("alice", "json");

    expect(exporter.calls).toHaveLength(1);
    expect(exporter.calls[0]).toEqual({ subjectId: "alice", format: "json" });
  });

  it("returns a UserDataBundle with the correct shape", async () => {
    const exporter = new RecordingDataExport();
    const bundle = await exporter.exportSubjectData("bob", "json-ld");

    expect(bundle.subjectId).toBe("bob");
    expect(bundle.format).toBe("json-ld");
    expect(typeof bundle.exportedAt).toBe("string");
    expect(bundle.data).toEqual({});
  });

  it("records multiple calls in order", async () => {
    const exporter = new RecordingDataExport();
    await exporter.exportSubjectData("alice", "json");
    await exporter.exportSubjectData("bob", "json-ld");

    expect(exporter.calls).toHaveLength(2);
    expect(exporter.calls[0]?.subjectId).toBe("alice");
    expect(exporter.calls[1]?.subjectId).toBe("bob");
  });

  it("reset() clears recorded calls", async () => {
    const exporter = new RecordingDataExport();
    await exporter.exportSubjectData("alice", "json");
    exporter.reset();

    expect(exporter.calls).toHaveLength(0);
  });
});
