import { expect, test } from "bun:test";
import { testPluginCompatibility } from "../src/index.ts";

test("plugin compatibility kit evaluates runtime, Bun, OS, and capability matrices", () => {
  const results = testPluginCompatibility(
    {
      runtimes: ["bun", "node"],
      requires: ["filesystem"],
      compatibility: { bunMin: "1.3.0", os: ["linux", "darwin"] },
    },
    [
      { runtime: "bun", version: "1.3.2", os: "linux", capabilities: ["filesystem"] },
      { runtime: "bun", version: "1.2.9", os: "win32", capabilities: [] },
      { runtime: "edge", os: "linux", capabilities: ["crypto"] },
    ],
  );
  expect(results[0]?.ok).toBe(true);
  expect(results[1]?.issues.map((issue) => issue.code)).toEqual([
    "WRN-PLUGIN-MATRIX-VERSION",
    "WRN-PLUGIN-MATRIX-OS",
    "WRN-PLUGIN-MATRIX-CAPABILITY",
  ]);
  expect(results[2]?.issues.map((issue) => issue.code)).toEqual([
    "WRN-PLUGIN-MATRIX-RUNTIME",
    "WRN-PLUGIN-MATRIX-CAPABILITY",
  ]);
});
