import { describe, it, expect } from "vitest";
import { extractPathParams, inferResourceType, } from "../../../scanners/logic/endpoint-analyzer.js";
describe("endpoint-analyzer", () => {
    describe("extractPathParams", () => {
        it("extracts Express-style colon params", () => {
            const params = extractPathParams("/api/users/:id/posts/:postId");
            expect(params).toContain("id");
            expect(params).toContain("postId");
        });
        it("extracts Next.js-style bracket params", () => {
            const params = extractPathParams("/api/users/[id]/posts/[postId]");
            expect(params).toContain("id");
            expect(params).toContain("postId");
        });
        it("extracts Flask/Django-style angle bracket params", () => {
            const params = extractPathParams("/api/users/<id>/posts/<post_id:int>");
            expect(params).toContain("id");
            expect(params).toContain("post_id");
        });
        it("extracts Spring-style curly brace params", () => {
            const params = extractPathParams("/api/users/{id}/posts/{postId}");
            expect(params).toContain("id");
            expect(params).toContain("postId");
        });
        it("returns empty array for paths without params", () => {
            const params = extractPathParams("/api/users/all");
            expect(params).toHaveLength(0);
        });
        it("handles mixed parameter styles", () => {
            const params = extractPathParams("/api/:userId/[orderId]");
            expect(params).toContain("userId");
            expect(params).toContain("orderId");
        });
    });
    describe("inferResourceType", () => {
        it("infers resource from API path", () => {
            expect(inferResourceType("/api/users")).toBe("user");
            expect(inferResourceType("/api/v1/orders")).toBe("order");
            expect(inferResourceType("/api/products/123")).toBe("product");
        });
        it("handles pluralized resources correctly", () => {
            expect(inferResourceType("/api/categories")).toBe("category");
            expect(inferResourceType("/api/companies")).toBe("company");
            expect(inferResourceType("/api/addresses")).toBe("address");
        });
        it("extracts first resource segment from nested paths", () => {
            // The function extracts the first resource segment after /api/v*
            expect(inferResourceType("/api/v2/admin/users")).toBe("admin");
        });
        it("returns undefined for root paths", () => {
            expect(inferResourceType("/")).toBeUndefined();
        });
    });
});
//# sourceMappingURL=endpoint-analyzer.test.js.map