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

describe("RecordingDataDelete", () => {
  it("records deleteSubjectData calls", async () => {
    const deleter = new RecordingDataDelete();
    await deleter.deleteSubjectData("alice", "soft");

    expect(deleter.calls).toHaveLength(1);
    expect(deleter.calls[0]).toEqual({ subjectId: "alice", mode: "soft" });
  });

  it("returns a DeletionCertificate with the correct shape", async () => {
    const deleter = new RecordingDataDelete();
    const cert = await deleter.deleteSubjectData("alice", "cascade-hard");

    expect(cert.subjectId).toBe("alice");
    expect(cert.mode).toBe("cascade-hard");
    expect(cert.reason).toBe("art-17-request");
    expect(cert.affected).toEqual([]);
    expect(typeof cert.auditEntryId).toBe("string");
    expect(typeof cert.timestamp).toBe("string");
  });

  it("records multiple calls in order", async () => {
    const deleter = new RecordingDataDelete();
    await deleter.deleteSubjectData("alice", "soft");
    await deleter.deleteSubjectData("bob", "cascade-hard");

    expect(deleter.calls[0]?.mode).toBe("soft");
    expect(deleter.calls[1]?.mode).toBe("cascade-hard");
  });

  it("reset() clears recorded calls", async () => {
    const deleter = new RecordingDataDelete();
    await deleter.deleteSubjectData("alice", "soft");
    deleter.reset();

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