"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const pattern_utils_1 = require("../pattern-utils");
describe('PatternUtils', () => {
    let utils;
    beforeEach(() => {
        utils = new pattern_utils_1.PatternUtils();
    });
    it('obfuscates project name', () => {
        const hash = utils.obfuscateProjectName('my-secret-project');
        expect(hash).toBeDefined();
        expect(hash.length).toBe(12);
        expect(hash).not.toBe('my-secret-project');
    });
    it('paginates items', () => {
        const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
        const page1 = utils.paginate(items, 1, 3);
        expect(page1.items).toEqual([1, 2, 3]);
        expect(page1.total).toBe(10);
        expect(page1.totalPages).toBe(4);
        const page2 = utils.paginate(items, 2, 3);
        expect(page2.items).toEqual([4, 5, 6]);
    });
    it('builds index and queries by category', () => {
        utils.buildIndex([
            { patternId: '1', category: 'react' },
            { patternId: '2', category: 'react' },
            { patternId: '3', category: 'node' },
        ]);
        expect(utils.queryByCategory('react').length).toBe(2);
        expect(utils.queryByCategory('node').length).toBe(1);
        expect(utils.queryByCategory('nonexistent').length).toBe(0);
    });
    it('queries by minimum confidence', () => {
        utils.buildIndex([
            { patternId: '1', category: 'react', confidence: { mean: 0.9 } },
            { patternId: '2', category: 'react', confidence: { mean: 0.5 } },
        ]);
        expect(utils.queryByConfidence(0.7).length).toBe(1);
        expect(utils.queryByConfidence(0.4).length).toBe(2);
    });
    it('returns index stats', () => {
        utils.buildIndex([
            { patternId: '1', category: 'react' },
            { patternId: '2', category: 'node' },
        ]);
        const stats = utils.getIndexStats();
        expect(stats.categories).toBe(2);
        expect(stats.totalIndexed).toBe(2);
    });
});
//# sourceMappingURL=pattern-utils.test.js.map