All files / src/tests/testMocks mockTypes.ts

61.53% Statements 8/13
75% Branches 3/4
50% Functions 3/6
61.53% Lines 8/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150            18x                     18x                                                                 18x                                                                                                               18x                                     18x                       257x           7x   5x        
import { SecurityLevel } from "../../types/cia";
import { CIAComponentType } from "../../types/cia-services";
 
/**
 * Standard security levels for testing
 */
export const TEST_SECURITY_LEVELS: SecurityLevel[] = [
  "None",
  "Low",
  "Moderate",
  "High",
  "Very High",
];
 
/**
 * Standard CIA components for testing
 */
export const TEST_CIA_COMPONENTS: CIAComponentType[] = [
  "availability",
  "integrity",
  "confidentiality",
];
 
/**
 * Creates test cases for all combinations of components and security levels
 */
export function createComponentLevelTestCases() {
  const testCases: Array<{
    component: CIAComponentType;
    level: SecurityLevel;
  }> = [];
 
  TEST_CIA_COMPONENTS.forEach((component) => {
    TEST_SECURITY_LEVELS.forEach((level) => {
      testCases.push({ component, level });
    });
  });
 
  return testCases;
}
 
/**
 * Default mock options for security level testing
 *
 * ## Business Perspective
 *
 * This provides consistent security options across tests, ensuring
 * predictable testing of security level classifications and
 * maintaining alignment with business requirements. 🔒
 */
export const DEFAULT_MOCK_OPTIONS = {
  None: {
    description: "No security controls",
    technical: "No technical controls implemented",
    businessImpact: "Critical business impact",
    capex: 0,
    opex: 0,
    bg: "#ffffff",
    text: "#000000",
    recommendations: [],
  },
  Low: {
    description: "Basic security controls",
    technical: "Basic technical controls",
    businessImpact: "High business impact",
    capex: 5,
    opex: 2,
    bg: "#f8d7da",
    text: "#721c24",
    recommendations: ["Basic recommendation"],
  },
  Moderate: {
    description: "Standard security controls",
    technical: "Standard technical controls",
    businessImpact: "Medium business impact",
    capex: 10,
    opex: 5,
    bg: "#fff3cd",
    text: "#856404",
    recommendations: ["Standard recommendation"],
  },
  High: {
    description: "Advanced security controls",
    technical: "Advanced technical controls",
    businessImpact: "Low business impact",
    capex: 15,
    opex: 8,
    bg: "#d4edda",
    text: "#155724",
    recommendations: ["Advanced recommendation"],
  },
  "Very High": {
    description: "Maximum security controls",
    technical: "Maximum technical controls",
    businessImpact: "Minimal business impact",
    capex: 20,
    opex: 10,
    bg: "#cce5ff",
    text: "#004085",
    recommendations: ["Maximum recommendation"],
  },
};
 
/**
 * Default mock ROI estimates
 */
export const DEFAULT_ROI_ESTIMATES = {
  NONE: { returnRate: "0%", description: "No ROI", value: "0%" },
  LOW: { returnRate: "50%", description: "Low ROI", value: "50%" },
  MODERATE: {
    returnRate: "150%",
    description: "Moderate ROI",
    value: "150%",
  },
  HIGH: { returnRate: "300%", description: "High ROI", value: "300%" },
  VERY_HIGH: {
    returnRate: "500%",
    description: "Very high ROI",
    value: "500%",
  },
};
 
/**
 * Default security icons mapping
 */
export const DEFAULT_SECURITY_ICONS: Record<SecurityLevel, string> = {
  None: "⚠️",
  Low: "🔑",
  Moderate: "🔓",
  High: "🔒",
  "Very High": "🔐",
};
 
/**
 * Default mock data provider that can be used in tests
 */
export function createMockDataProvider() {
  return {
    availabilityOptions: DEFAULT_MOCK_OPTIONS,
    integrityOptions: DEFAULT_MOCK_OPTIONS,
    confidentialityOptions: DEFAULT_MOCK_OPTIONS,
    roiEstimates: DEFAULT_ROI_ESTIMATES,
    getDefaultSecurityIcon: (level: SecurityLevel) =>
      DEFAULT_SECURITY_ICONS[level] || "❓",
    getDefaultValuePoints: (level: SecurityLevel) => {
      return level === "None" ? [] : [`Test value point for ${level}`];
    },
  };
}