import { describe, it, expectTypeOf } from "vitest"; import type { IRateLimit, RateLimitBudget, RateLimitDecision, } from "@/rate-limit/rate-limit.interface"; describe("rate-limit types", () => { it("RateLimitBudget has the expected shape", () => { expectTypeOf().toMatchTypeOf<{ name: string; window: string; budget: number; }>(); }); it("RateLimitDecision has the expected shape", () => { expectTypeOf().toMatchTypeOf<{ allowed: boolean; remaining: number; resetAt: Date; }>(); }); it("IRateLimit.consume returns Promise", () => { expectTypeOf< IRateLimit["consume"] >().returns.resolves.toEqualTypeOf(); }); it("IRateLimit.consume accepts optional weight", () => { type ConsumeParams = Parameters; expectTypeOf().toEqualTypeOf(); expectTypeOf().toEqualTypeOf(); expectTypeOf().toEqualTypeOf(); }); it("IRateLimit.reset returns Promise", () => { expectTypeOf().returns.resolves.toEqualTypeOf(); }); });