/**
 * Tests for SOC 2 controls
 */
import { describe, it, expect } from "vitest";
import { SOC2_CONTROLS, getSOC2Controls, getSOC2ControlsByCategory, getSOC2ControlById, getSOC2Categories, } from "./soc2.js";
describe("SOC 2 controls", () => {
    describe("SOC2_CONTROLS", () => {
        it("has controls defined", () => {
            expect(SOC2_CONTROLS.length).toBeGreaterThan(0);
        });
        it("all controls have required fields", () => {
            for (const control of SOC2_CONTROLS) {
                expect(control.id).toBeDefined();
                expect(control.framework).toBe("SOC2");
                expect(control.category).toBeDefined();
                expect(control.title).toBeDefined();
                expect(control.description).toBeDefined();
                expect(control.keywords).toBeInstanceOf(Array);
                expect(control.findingCategories).toBeInstanceOf(Array);
            }
        });
        it("has unique control IDs", () => {
            const ids = SOC2_CONTROLS.map((c) => c.id);
            const uniqueIds = new Set(ids);
            expect(uniqueIds.size).toBe(ids.length);
        });
        it("includes Common Criteria controls (CC)", () => {
            const ccControls = SOC2_CONTROLS.filter((c) => c.id.startsWith("CC"));
            expect(ccControls.length).toBeGreaterThan(0);
        });
        it("includes Confidentiality controls (C)", () => {
            const cControls = SOC2_CONTROLS.filter((c) => c.id.startsWith("C1"));
            expect(cControls.length).toBeGreaterThan(0);
        });
        it("includes Availability controls (A)", () => {
            const aControls = SOC2_CONTROLS.filter((c) => c.id.startsWith("A1"));
            expect(aControls.length).toBeGreaterThan(0);
        });
        it("includes Processing Integrity controls (PI)", () => {
            const piControls = SOC2_CONTROLS.filter((c) => c.id.startsWith("PI"));
            expect(piControls.length).toBeGreaterThan(0);
        });
    });
    describe("getSOC2Controls", () => {
        it("returns all controls", () => {
            const controls = getSOC2Controls();
            expect(controls).toEqual(SOC2_CONTROLS);
        });
    });
    describe("getSOC2ControlsByCategory", () => {
        it("returns controls for valid category", () => {
            const controls = getSOC2ControlsByCategory("Logical and Physical Access");
            expect(controls.length).toBeGreaterThan(0);
            expect(controls.every((c) => c.category === "Logical and Physical Access")).toBe(true);
        });
        it("returns empty array for invalid category", () => {
            const controls = getSOC2ControlsByCategory("Invalid Category");
            expect(controls).toEqual([]);
        });
    });
    describe("getSOC2ControlById", () => {
        it("returns control for valid ID", () => {
            const control = getSOC2ControlById("CC6.1");
            expect(control).toBeDefined();
            expect(control.id).toBe("CC6.1");
        });
        it("returns undefined for invalid ID", () => {
            const control = getSOC2ControlById("INVALID");
            expect(control).toBeUndefined();
        });
    });
    describe("getSOC2Categories", () => {
        it("returns unique categories", () => {
            const categories = getSOC2Categories();
            expect(categories.length).toBeGreaterThan(0);
            const uniqueCategories = new Set(categories);
            expect(uniqueCategories.size).toBe(categories.length);
        });
        it("includes expected categories", () => {
            const categories = getSOC2Categories();
            expect(categories).toContain("Logical and Physical Access");
            expect(categories).toContain("System Operations");
        });
    });
});
//# sourceMappingURL=soc2.test.js.map