"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const build_failure_predictor_1 = require("../../walls/03-knowledge/decisions/build-failure-predictor");
describe('BuildFailurePredictor', () => {
    let predictor;
    beforeEach(() => {
        predictor = new build_failure_predictor_1.BuildFailurePredictor();
    });
    test('detects implicit any', () => {
        const code = 'function foo(x: any) { return x; }';
        const predictions = predictor.predictTypeScript(code);
        expect(predictions.some((p) => p.type === 'ts_error')).toBe(true);
    });
    test('detects var usage for ESLint', () => {
        const code = 'var x = 1;';
        const predictions = predictor.predictESLint(code);
        expect(predictions.some((p) => p.type === 'eslint_violation')).toBe(true);
    });
    test('detects loose equality', () => {
        const code = 'if (x == null) { }';
        const predictions = predictor.predictESLint(code);
        expect(predictions.some((p) => p.type === 'eslint_violation')).toBe(true);
    });
    test('detects console statements', () => {
        const code = 'console.log("debug");';
        const predictions = predictor.predictESLint(code);
        expect(predictions.some((p) => p.type === 'eslint_violation')).toBe(true);
    });
    test('predictAll returns all categories', () => {
        const code = 'var x: any = 1;\nconsole.log(x);';
        const result = predictor.predictAll(code);
        expect(result.tsErrors.length + result.eslintViolations.length + result.testFailures.length).toBeGreaterThan(0);
    });
    test('getAutoFixable filters correctly', () => {
        const code = 'var x = 1;\nif (x == null) { }';
        const predictions = predictor.predictESLint(code);
        const fixable = predictor.getAutoFixable(predictions);
        expect(fixable.length).toBeGreaterThan(0);
        expect(fixable.every((p) => p.autoFixable)).toBe(true);
    });
    test('getStats returns correct structure', () => {
        const code = 'var x = 1;';
        const predictions = predictor.predictESLint(code);
        const stats = predictor.getStats(predictions);
        expect(stats.total).toBeGreaterThan(0);
        expect(stats.autoFixable).toBeGreaterThanOrEqual(0);
        expect(stats.byType).toBeDefined();
    });
    test('returns empty for clean code', () => {
        const code = 'const x = 1;';
        const result = predictor.predictAll(code);
        const all = [...result.tsErrors, ...result.eslintViolations, ...result.testFailures];
        expect(all).toHaveLength(0);
    });
    test('AST detects any type annotation', () => {
        const code = 'function process(data: any) { return data; }';
        const predictions = predictor.predictTypeScript(code);
        expect(predictions.some((p) => p.type === 'ts_error' && p.message.includes('any'))).toBe(true);
    });
    test('AST ignores non-any types', () => {
        const code = 'function process(data: string) { return data; }';
        const predictions = predictor.predictTypeScript(code);
        expect(predictions.some((p) => p.type === 'ts_error')).toBe(false);
    });
    test('AST detects var keyword', () => {
        const code = 'var count = 0;';
        const predictions = predictor.predictESLint(code);
        expect(predictions.some((p) => p.type === 'eslint_violation' && p.message.includes('var'))).toBe(true);
    });
    test('AST ignores const/let', () => {
        const code = 'const count = 0;\nlet total = 0;';
        const predictions = predictor.predictESLint(code);
        expect(predictions.some((p) => p.type === 'eslint_violation' && p.message.includes('var'))).toBe(false);
    });
});
//# sourceMappingURL=build-failure-predictor.test.js.map