/**
 * Unit tests for scanner types module
 */
import { describe, it, expect } from "vitest";
import { SEVERITY_MAPPINGS, DEFAULT_SCANNER_OPTIONS, toFindingId, } from "./types.js";
describe("SEVERITY_MAPPINGS", () => {
    describe("npm severity mapping", () => {
        it("maps critical to critical", () => {
            expect(SEVERITY_MAPPINGS.npm.critical).toBe("critical");
        });
        it("maps high to high", () => {
            expect(SEVERITY_MAPPINGS.npm.high).toBe("high");
        });
        it("maps moderate to medium", () => {
            expect(SEVERITY_MAPPINGS.npm.moderate).toBe("medium");
        });
        it("maps low to low", () => {
            expect(SEVERITY_MAPPINGS.npm.low).toBe("low");
        });
        it("maps info to info", () => {
            expect(SEVERITY_MAPPINGS.npm.info).toBe("info");
        });
    });
    describe("semgrep severity mapping", () => {
        it("maps ERROR to high", () => {
            expect(SEVERITY_MAPPINGS.semgrep.ERROR).toBe("high");
        });
        it("maps WARNING to medium", () => {
            expect(SEVERITY_MAPPINGS.semgrep.WARNING).toBe("medium");
        });
        it("maps INFO to low", () => {
            expect(SEVERITY_MAPPINGS.semgrep.INFO).toBe("low");
        });
    });
    describe("gitleaks severity mapping", () => {
        it("maps all secrets to critical", () => {
            expect(SEVERITY_MAPPINGS.gitleaks.default).toBe("critical");
        });
    });
    describe("typescript severity mapping", () => {
        it("maps error to high", () => {
            expect(SEVERITY_MAPPINGS.typescript.error).toBe("high");
        });
        it("maps warning to medium", () => {
            expect(SEVERITY_MAPPINGS.typescript.warning).toBe("medium");
        });
        it("maps suggestion to low", () => {
            expect(SEVERITY_MAPPINGS.typescript.suggestion).toBe("low");
        });
        it("maps message to info", () => {
            expect(SEVERITY_MAPPINGS.typescript.message).toBe("info");
        });
    });
});
describe("DEFAULT_SCANNER_OPTIONS", () => {
    it("enables semgrep by default", () => {
        expect(DEFAULT_SCANNER_OPTIONS.semgrep).toBe(true);
    });
    it("enables dependencies by default", () => {
        expect(DEFAULT_SCANNER_OPTIONS.dependencies).toBe(true);
    });
    it("enables secrets by default", () => {
        expect(DEFAULT_SCANNER_OPTIONS.secrets).toBe(true);
    });
    it("enables typescript by default", () => {
        expect(DEFAULT_SCANNER_OPTIONS.typescript).toBe(true);
    });
    it("disables eslint by default", () => {
        expect(DEFAULT_SCANNER_OPTIONS.eslint).toBe(false);
    });
    it("sets timeout to 2 minutes", () => {
        expect(DEFAULT_SCANNER_OPTIONS.timeout).toBe(120000);
    });
});
describe("toFindingId", () => {
    it("generates semgrep finding ID with sem prefix", () => {
        expect(toFindingId("semgrep", "owasp.sql-injection", 0)).toBe("sem-001");
        expect(toFindingId("semgrep", "owasp.xss", 9)).toBe("sem-010");
        expect(toFindingId("semgrep", "rule", 99)).toBe("sem-100");
    });
    it("generates npm-audit finding ID with dep prefix", () => {
        expect(toFindingId("npm-audit", "lodash", 0)).toBe("dep-001");
        expect(toFindingId("npm-audit", "express", 4)).toBe("dep-005");
    });
    it("generates gitleaks finding ID with sec prefix", () => {
        expect(toFindingId("gitleaks", "aws-access-key", 0)).toBe("sec-001");
        expect(toFindingId("gitleaks", "github-token", 2)).toBe("sec-003");
    });
    it("generates tsc finding ID with ts prefix", () => {
        expect(toFindingId("tsc", "any-usage", 0)).toBe("ts-001");
        expect(toFindingId("tsc", "ts-ignore", 5)).toBe("ts-006");
    });
    it("generates eslint finding ID with lint prefix", () => {
        expect(toFindingId("eslint", "no-console", 0)).toBe("lint-001");
        expect(toFindingId("eslint", "prefer-const", 3)).toBe("lint-004");
    });
    it("pads index to 3 digits", () => {
        expect(toFindingId("semgrep", "rule", 0)).toBe("sem-001");
        expect(toFindingId("semgrep", "rule", 99)).toBe("sem-100");
        expect(toFindingId("semgrep", "rule", 999)).toBe("sem-1000"); // Overflow, but still works
    });
});
//# sourceMappingURL=types.test.js.map