import { describe, expect, it } from "vitest";

describe("Paystack credentials", () => {
  it("can authenticate against Paystack's lightweight transaction endpoint", async () => {
    const secret = process.env.PAYSTACK_SECRET_KEY;
    expect(secret, "PAYSTACK_SECRET_KEY must be configured").toMatch(/^sk_(test|live)_/);

    const response = await fetch("https://api.paystack.co/transaction", {
      headers: { Authorization: `Bearer ${secret}` },
    });

    expect(response.status).not.toBe(401);
    expect(response.status).not.toBe(403);
    expect(response.ok, `Paystack request failed with HTTP ${response.status}`).toBe(true);
    const body = await response.json() as { status?: boolean };
    expect(body.status).toBe(true);
  }, 15000);
});
