"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const complexity_analyzer_1 = require("../complexity-analyzer");
describe('ComplexityAnalyzer', () => {
    let analyzer;
    beforeEach(() => {
        analyzer = new complexity_analyzer_1.ComplexityAnalyzer();
    });
    test('analyzes simple function', () => {
        const code = 'function add(a: number, b: number): number {\n  return a + b;\n}';
        const reports = analyzer.analyze(code, 'test.ts');
        expect(reports.length).toBe(1);
        expect(reports[0].function).toBe('add');
        expect(reports[0].level).toBe('low');
    });
    test('detects high complexity function', () => {
        const code = `function complex(x: number): string {
  if (x > 0) {
    if (x > 10) {
      if (x > 20) {
        for (let i = 0; i < x; i++) {
          if (i % 2 === 0) {
            while (x > 0) {
              if (x === 5) return 'five';
            }
          }
        }
      }
    }
  }
  return 'done';
}`;
        const reports = analyzer.analyze(code, 'test.ts');
        expect(reports[0].complexity).toBeGreaterThan(5);
    });
    test('getHotspots filters low complexity', () => {
        const code = 'function simple() { return 1; }\nfunction complex(x: number): string {\n  if (x > 0) {\n    if (x > 10) {\n      if (x > 20) {\n        for (let i = 0; i < x; i++) {\n          if (i % 2 === 0) return "even";\n        }\n      }\n    }\n  }\n  return "done";\n}';
        const reports = analyzer.analyze(code, 'test.ts');
        const hotspots = analyzer.getHotspots(reports);
        expect(hotspots.length).toBeLessThanOrEqual(reports.length);
    });
    test('getStats returns correct structure', () => {
        const code = 'function a() {\n  return 1;\n}\nfunction b(x: number) {\n  if (x) { return 2; }\n  return 3;\n}';
        const reports = analyzer.analyze(code, 'test.ts');
        expect(reports.length).toBeGreaterThanOrEqual(1);
    });
    test('getHeatmapData groups by file', () => {
        const code = 'function a() {\n  return 1;\n}\nfunction b(x: number) {\n  if (x) { return 2; }\n  return 3;\n}';
        const reports = analyzer.analyze(code, 'test.ts');
        const heatmap = analyzer.getHeatmapData(reports);
        expect(heatmap.length).toBeGreaterThanOrEqual(0);
    });
});
//# sourceMappingURL=complexity-analyzer.test.js.map