import { describe, it, expect } from "vitest";
import { RATE_LIMIT, isWithinLimit } from "../rate-limit";

describe("rate-limit policy", () => {
  it("erlaubt max. 5 Fehlversuche pro Fenster", () => {
    expect(RATE_LIMIT.maxFails).toBe(5);
    expect(RATE_LIMIT.windowMs).toBe(15 * 60 * 1000);
  });

  it("ist innerhalb des Limits bei < maxFails", () => {
    expect(isWithinLimit(0)).toBe(true);
    expect(isWithinLimit(4)).toBe(true);
  });

  it("blockiert ab maxFails (6. Versuch)", () => {
    expect(isWithinLimit(5)).toBe(false);
    expect(isWithinLimit(6)).toBe(false);
  });
});
