"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const extraction_cascade_1 = require("../extraction-cascade");
(0, vitest_1.describe)('ExtractionCascade', () => {
    const cascade = new extraction_cascade_1.ExtractionCascade();
    (0, vitest_1.it)('detects language from TS code', () => {
        (0, vitest_1.expect)(cascade.detectLanguage('const x: string = "hello";')).toBe('typescript');
    });
    (0, vitest_1.it)('detects language from JS code', () => {
        (0, vitest_1.expect)(cascade.detectLanguage('const x = require("fs");')).toBe('javascript');
    });
    (0, vitest_1.it)('returns hint for AST languages only', () => {
        (0, vitest_1.expect)(cascade.detectLanguage('', 'typescript')).toBe('typescript');
        (0, vitest_1.expect)(cascade.detectLanguage('', 'javascript')).toBe('javascript');
    });
    (0, vitest_1.it)('ignores hint for non-AST languages', () => {
        (0, vitest_1.expect)(cascade.detectLanguage('hello world', 'python')).toBe('unknown');
    });
    (0, vitest_1.it)('returns unknown for ambiguous code', () => {
        (0, vitest_1.expect)(cascade.detectLanguage('hello world')).toBe('unknown');
    });
    (0, vitest_1.it)('uses AST for TypeScript code', () => {
        const result = cascade.extract('let x = 1;', 'const x = 1;', 'typescript');
        (0, vitest_1.expect)(result.stepUsed).toBe('ast');
        (0, vitest_1.expect)(result.patterns.length).toBeGreaterThan(0);
    });
    (0, vitest_1.it)('auto-detects TypeScript from code content', () => {
        const result = cascade.extract('let x: number = 1;', 'const x: number = 1;');
        (0, vitest_1.expect)(result.stepUsed).toBe('ast');
        (0, vitest_1.expect)(result.patterns.length).toBeGreaterThan(0);
    });
    (0, vitest_1.it)('returns empty for identical code', () => {
        const result = cascade.extract('const x = 1;', 'const x = 1;', 'typescript');
        (0, vitest_1.expect)(result.patterns.length).toBe(0);
    });
    (0, vitest_1.it)('extractAll combines all extractors', () => {
        const result = cascade.extractAll('let x = 1;', 'const x = 1;', 'typescript');
        (0, vitest_1.expect)(result.patterns.length).toBeGreaterThan(0);
        (0, vitest_1.expect)(result.stepUsed).toBe('ast');
    });
    (0, vitest_1.it)('audit returns security and error results', () => {
        const result = cascade.audit('document.getElementById("x").innerHTML = userInput;');
        (0, vitest_1.expect)(result.security.length).toBeGreaterThan(0);
        (0, vitest_1.expect)(result.security[0].type).toBe('xss');
    });
    (0, vitest_1.it)('audit returns empty for clean code', () => {
        const result = cascade.audit('const x = 42;');
        (0, vitest_1.expect)(result.security.length).toBe(0);
        (0, vitest_1.expect)(result.errors.length).toBe(0);
    });
    (0, vitest_1.it)('getStats returns pattern counts', () => {
        const stats = cascade.getStats();
        (0, vitest_1.expect)(stats.astPatterns).toBe(11);
        (0, vitest_1.expect)(stats.regexPatterns).toBe(9);
        (0, vitest_1.expect)(stats.heuristicCapabilities).toBe(4);
    });
});
//# sourceMappingURL=extraction-cascade.test.js.map