import { describe, it, expect, vi } from "vitest";
import { pdfMergerPlugin } from "./index";
import { runPdfMerger } from "./run";
import type { ToolContext } from "../../core/plugins/plugin-types";

describe("PDF Merger Plugin", () => {
  const mockContext: ToolContext = {
    signal: new AbortController().signal,
    reportProgress: vi.fn(),
    logger: {
      info: vi.fn(),
      warn: vi.fn(),
      error: vi.fn(),
    },
  };

  it("should have correct manifest", () => {
    expect(pdfMergerPlugin.manifest.id).toBe("pdf-merger");
    expect(pdfMergerPlugin.manifest.input.type).toBe("files");
    expect(pdfMergerPlugin.manifest.output.type).toBe("files");
  });

  it("should have run function", () => {
    expect(pdfMergerPlugin.run).toBeDefined();
  });

  it("should throw error if no files provided", async () => {
    await expect(
      runPdfMerger({ files: [] }, {}, mockContext)
    ).rejects.toThrow("No files provided for merging.");
  });
});
