"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const regex_extractor_1 = require("../regex-extractor");
describe('RegexExtractor', () => {
    let extractor;
    beforeEach(() => {
        extractor = new regex_extractor_1.RegexExtractor();
    });
    test('detects var to const/let change', () => {
        const results = extractor.extractFromDiff('var x = 1', 'const x = 1');
        expect(results.length).toBeGreaterThan(0);
        expect(results.some((r) => r.category === 'variable_declaration')).toBe(true);
    });
    test('detects function to arrow function change', () => {
        const results = extractor.extractFromDiff('function foo() { return 1; }', 'const foo = () => { return 1; }');
        expect(results.some((r) => r.category === 'function_style')).toBe(true);
    });
    test('detects require to import change', () => {
        const results = extractor.extractFromDiff("const fs = require('fs')", "import fs from 'fs'");
        expect(results.some((r) => r.category === 'module_system')).toBe(true);
    });
    test('detects .then() to await change', () => {
        const results = extractor.extractFromDiff('fetch(url).then(r => r.json())', 'const r = await fetch(url); const data = await r.json()');
        expect(results.some((r) => r.category === 'promise_style')).toBe(true);
    });
    test('detects default to named export change', () => {
        const results = extractor.extractFromDiff('export default function App() {}', 'export function App() {}');
        expect(results.some((r) => r.category === 'export_style')).toBe(true);
    });
    test('detects loose to strict equality change', () => {
        const results = extractor.extractFromDiff('if (x == null)', 'if (x === null)');
        expect(results.some((r) => r.category === 'equality')).toBe(true);
    });
    test('returns empty for identical code', () => {
        const results = extractor.extractFromDiff('const x = 1', 'const x = 1');
        expect(results).toHaveLength(0);
    });
    test('extractFromDiff returns patterns with confidence delta', () => {
        const results = extractor.extractFromDiff('var x = 1', 'const x = 1');
        for (const r of results) {
            expect(r.confidenceDelta).toBeGreaterThan(0);
            expect(r.confidenceDelta).toBeLessThanOrEqual(0.15);
        }
    });
    test('getPatternCount returns correct number', () => {
        expect(extractor.getPatternCount()).toBe(9);
    });
});
//# sourceMappingURL=regex-extractor.test.js.map